CodeIgniter removing index.php from url
Asked Answered
S

35

176

My current urls look like this [mysite]index.php/[rest of the slug].
I want to strip index.php from these urls.

mod_rewrite is enabled on my apache2 server. In config, $config['index_page'] = '';

My codeignitor root .htaccess file contains,

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

But still it is not working. Where am I going wrong?

Surety answered 4/10, 2013 at 14:4 Comment(2)
possible duplicate of How to remove "index.php" in codeigniter's pathHatley
Why does this question have so many duplicate answersBailey
S
253

Try the following

Open config.php and do following replaces

$config['index_page'] = "index.php"

to

$config['index_page'] = ""

In some cases the default setting for uri_protocol does not work properly. Just replace

$config['uri_protocol'] ="AUTO"

by

$config['uri_protocol'] = "REQUEST_URI"

.htaccess

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA] 

Note: .htaccess code vary depending on hosting server. In some hosting server (e.g.: Godaddy) need to use an extra ? in the last line of above code. The following line will be replaced with last line in applicable case:

// Replace last .htaccess line with this line
RewriteRule ^(.*)$ index.php?/$1 [L,QSA] 
Schuh answered 5/10, 2013 at 11:6 Comment(9)
I've tried this code RewriteRule ^(.*)$ index.php/$1 [L] But still I can view the page in both way domain.com/about-us , domain.com/index.php/about-us and domain.com/index.php?/about-us which generating SEO error i.e duplicate title tag and duplicate meta descriptionArtful
Thank you for the answer, I got the same problem and adding the first RewriteCond make it works. Can you elaborate on why the manual (here: codeigniter.com/userguide3/general/…) doesn't mention it?Phenazine
Thank you for your answer, i got same problem from tank-authNavigator
$_POST or isset($_POST) not working after adding this.Fortify
I am using angularjs on the client side ... changing the htaccess results in a client-side error: Failed to parse SourceMap: http:// ... /angular.min.js.map WHEN I use angular.js from local copy ... BUT IF I use angular.js from https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js, no error occursImplausible
and dont forget to change the apache configuration as mentioned in https://mcmap.net/q/144316/-codeigniter-htaccess-and-url-rewrite-issuesFaceharden
tested on xampp, Works great, now I have clean urls! thanks!Scoreboard
In some hosting server ... need to use an extra ? in the last line of above code. - thanks, literally just ended half an hour of scratching my head.Dramatist
for codeigniter 4 index page configuration is inside app/config/App.php . the line is public string $indexPage = ''; along with .htaccess rules suggested here.Seersucker
B
146

Step:-1 Open the folder “application/config” and open the file “config.php“. find and replace the below code in config.php file.

//find the below code   
$config['index_page'] = "index.php" 
//replace with the below code
$config['index_page'] = ""

Step:-2 Go to your CodeIgniter folder and create .htaccess

Path:
Your_website_folder/
application/
assets/
system/
.htaccess <——— this file
index.php

Step:-3 Write below code in .htaccess file

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule>

Step:-4 In some case the default setting for uri_protocol does not work properly. To solve this problem just open the file “application/config/config.php“, then find and replace the below code

//Not needed for CodeIgniter 3 its already there.
//find the below code
$config['uri_protocol'] = "AUTO"
//replace with the below code
$config['uri_protocol'] = "REQUEST_URI" 

Thats all but in wamp server it does not work because rewrite_module by default disabled so we have need to enable it. for this do the following

  1. Left click WAMP icon
  2. Apache
  3. Apache Modules
  4. Left click rewrite_module

Original Documentation

Example Link

Buber answered 3/3, 2015 at 10:3 Comment(5)
i had to put the .htaccess in the root folder instead of "application" folder to make this workIliac
I don't have CodeIgniter folder. What are you talking about?Flatten
it removes index.php but I need to remove extra backslash'/' tooCivilized
after changing in config.php and creating .htaccess file . I am getting error Parse error: syntax error, unexpected '$config' (T_VARIABLE) in application\config\config.php on line 55Geminian
Thank you for the answer. For me, I needed to update my htaccess file as shown and then make sure it was a sibling of the system folder, not inside it.Exarate
E
54

Step 1 :

Add this in htaccess file

<IfModule mod_rewrite.c>
  RewriteEngine On
  #RewriteBase /

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^ index.php [QSA,L]
</IfModule>

Step 2 :

Remove index.php in codeigniter config

$config['base_url'] = ''; 
$config['index_page'] = '';

Step 3 :

Allow overriding htaccess in Apache Configuration (Command)

sudo nano /etc/apache2/apache2.conf

and edit the file & change to

AllowOverride All

for www folder

Step 4 :

Enabled apache mod rewrite (Command)

sudo a2enmod rewrite

Step 5 :

Restart Apache (Command)

sudo /etc/init.d/apache2 restart
Eternity answered 5/5, 2014 at 7:35 Comment(7)
"AllowOverride All" in apache2.conf solved the problem for me, as .htaccess filles are not used by default.Codd
I wish I could give you bonus for this! Saved my day. Spent 2 hours after this :|Tody
It seems for recent Linux Distros the first thing one needs to do is to edit the AllowOveride ruleMacegan
Finally got it to work. Thanks. AllowOveride rule help me with this problem. I'm using ubuntu 16.04Lupe
Excellent solution, Thanks :)Kraft
This solved it, my real problem was on the apache2 configurations server not CI files.Prowel
It is not necessary to set $config['base_url'] = '';. You can leave the base_url value set for your page and it will still work.Pentachlorophenol
R
17

Step 1 => Place your .htaccess file in root folder where application and system folders exist.

Step 2 => If your web path using sub-folder like - yourdomain.com/project/ - then use following code in htaccess file

RewriteEngine on
RewriteBase    /project/
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /project/index.php/$1 [L]

If your web path using root-folder like - yourdomain.com - then use following code in htaccess file

RewriteEngine on
RewriteBase    /
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
Redtop answered 4/9, 2014 at 9:27 Comment(2)
This is by far the best and complete answer. sub-folder thing is what makes it better than other answers.Galanti
This SHOULD be the answer. The voted answer with the part about: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d That didn't work for me.Aldine
N
16
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

use

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$1 [PT,L]

if you have url in this order site.com/index.php/class/method/id

NB:remove index.php in config.php should be config[index_page] = ""

NB: notice the difference at the last line instead of $0 use $1

Natator answered 26/3, 2014 at 15:10 Comment(3)
this works for me. Answers above don't. I haven't tested the answers below.Spinney
This worked for me but I had to change uri protocol from 'AUTO; to 'REQUEST_URI' like this: $config['uri_protocol'] = 'REQUEST_URI';Lampoon
RewriteRule .* index.php/$1 [PT,L] - this won't pass the URL-path unless you change the RewriteRule pattern from .* to (.*). However, if you're using $config['uri_protocol'] = 'REQUEST_URI'; then this is irrelevant anyway.Catron
Z
13

on your htaccess use this,

RewriteEngine On
RewriteBase /root_folder_name/
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond $1 !^(index\.php|images|js|uploads|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Hope this helps.

Zebada answered 4/10, 2013 at 14:8 Comment(3)
root_folder_name -> have you changed this with your root folder name ??Zebada
Yes, I did that. I put my codeigniter root there. Is that correct?Surety
Buddy I'm using this .htaccess code in two of my CI projects!! and both are working fine!!Zebada
D
11

There are two steps:

1) Edit config.php

$config['index_page'] = 'index.php';

To

$config['index_page'] = '’;

2) Create/Edit .htaccess file

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Dream answered 3/6, 2015 at 6:36 Comment(0)
M
8

Solved it with 2 steps.

  1. Update 2 parameters in the config file application/config/config.php
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
  1. Update the file .htaccess in the root folder
<IfModule mod_rewrite.c>
    RewriteEngine On
      RewriteBase /
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
Masqat answered 28/2, 2019 at 9:17 Comment(0)
D
7

1.Create a new file .htaccess on root directory.

<IfModule mod_rewrite.c>
RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule>`

2. Go to your config.php file and change from $config['index_page'] = 'index.php' to $config['index_page'] = ''

Demicanton answered 12/6, 2015 at 5:47 Comment(0)
B
6
  1. make .htaccess file and put this code

     RewriteEngine on
     RewriteCond $1 !^(index\.php|resources|robots\.txt)
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteRule ^(.*)$ index.php/$1 [L,QSA] 
    
  2. change

    $config['index_page'] = ''; 
    

remove index.php present in config.php file

  1. rewrite on from your server.
Basinet answered 6/10, 2016 at 7:53 Comment(0)
D
5

try this one.It may help you as its working for me.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

put the code in your root htaccess file.and make sure that you have

$config['index_page'] = '';

in your config file.

Please let me know if you face any problem.

Doge answered 5/10, 2013 at 7:47 Comment(1)
That's exactly what I was doing.Surety
S
4
+ Copy .htaccess from Application to Root folder
+ edit .htaccess and put

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /ci_test/

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

Note: make sure your web server is enable for  "rewrite_module"

+ Remove index.php from $config['index_page'] = 'index.php';
- edit config.php in application/config
- search for index.php
change it from  $config['index_page'] = 'index.php'; to  $config['index_page'] = '';

Please watch this videos for reference https://www.youtube.com/watch?v=HFG2nMDn35Q

Standice answered 23/7, 2015 at 2:9 Comment(0)
M
4

Well these all answers are good but for a newbie(which is do first time) these are confusing. There are other htaccess files which is reside in controller but we have to edit or add the htaccess in main project folder.

This is your codeigniter folder, where file resides like application,system,assets,uploads etc.

Your_project_folder/
application/
assets/
cgi-bin/
system/
.htaccess---->(Edit this file if not exist than create it)
index.php

Change this file as written below:

<IfModule mod_rewrite.c>
  RewriteEngine On
  # !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
  #  slashes.
  # If your page resides at http://www.example.com/mypage/test1
  # then use RewriteBase /mypage/test1/
  # Otherwise /
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
  # If we don't have mod_rewrite installed, all 404's
  # can be sent to index.php, and everything works as normal.
  # Submitted by: Anand Pandey
  ErrorDocument 404 /index.php
</IfModule>

and yes of course you need to change two lines of code in the application/config/config.php

//find the below code   
$config['index_page'] = "index.php";
$config['uri_protocol'] ="AUTO" 
//replace with the below code
$config['index_page'] = "";
$config['uri_protocol'] = "REQUEST_URI";
Madras answered 13/11, 2017 at 5:55 Comment(1)
For some reason all these answers does not work for me. I can access the pages when I add /index.php/ in url.Reaves
D
3

you can go to config\config.php file and remove index.php value from this variable

$config['index_page'] = 'index.php'; // delete index.php

create .htaccess file and paste this code in it.

<IfModule mod_rewrite.c>

 Options +FollowSymLinks

 RewriteEngine On
 #Send request via index.php
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^(.*)$ index.php/$1 [L]

</IfModule>

good chance

Dahlberg answered 11/4, 2014 at 21:16 Comment(0)
D
3

Both development and production

    # Development
    RewriteEngine On
    RewriteBase /your_local_folder/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 !^(index\.php|images|scripts|styles|vendor|robots\.txt)
    RewriteRule ^(.*)$ index.php/$1 [L]

    #Production PHP5 CGI mode
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 !^(index\.php|images|scripts|styles|vendor|robots\.txt)
    RewriteRule ^(.*)$ index.php?/$1 [L]
Dispassion answered 6/8, 2014 at 4:55 Comment(0)
P
3

first of all you have to on the apache server rewrite engine on.this link will help you for that

http://www.anmsaiful.net/blog/php/enable-apache-rewrite-module.html

RewriteEngine On
RewriteBase /your_folder_name/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?/$1 [L]

this will be your .htaccess file. now try it .this setting works for me.

Pontianak answered 15/1, 2015 at 5:56 Comment(0)
H
3

Add .htaccess on your root folder and past the following code:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
Highmuckamuck answered 28/7, 2021 at 8:39 Comment(0)
B
2
  Removing index.php from url of codeigniter   

Three steps are require to remove index.php from url in Codeigniter.

1)Create .htacess file in parallel to application holder and just copy past the following code:

RewriteEngine On
RewriteBase /CodeIgniter/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

2) Change $config['index_page'] to blank in config.php in application folder as below:

$config['index_page'] = '';

3) Enable “rewrite_module” of apache.
Bethea answered 3/6, 2014 at 13:17 Comment(0)
V
2

You can remove index.php from url by placing some code in .htaccess

File path: root > .htacess

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

Hope it will works.

Vomiturition answered 23/10, 2018 at 8:27 Comment(0)
P
1

Only three steps are require to remove index.php from url in Codeigniter

1) Create .htacess file in parallel to application holder and just copy past the following code:

RewriteEngine On
RewriteBase /CodeIgniter/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

2) Change $config['index_page'] to blank in config.php in application folder as below:

$config['index_page'] = '';

3) Enable “rewrite_module” of apache.

Restart your apache and its done.

Details : http://sforsuresh.in/removing-index-php-from-url-of-codeigniter-in-wamp/

Profluent answered 16/5, 2014 at 14:5 Comment(0)
S
1

I think your all setting is good but you doing to misplace your htaccess file go and add your htaccess to your project file

project_folder->htaccess

and add this code to your htaccess

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
Shaduf answered 30/5, 2016 at 5:57 Comment(0)
E
1

you can go to application\config\config.php file and remove index.php


 $config['index_page'] = 'index.php';   // delete index.php

Change to


 $config['index_page'] = '';

Emogeneemollient answered 10/8, 2017 at 17:25 Comment(0)
T
1

try this RewriteEngine On

        # Removes index.php from ExpressionEngine URLs
        RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
Tweezers answered 24/4, 2019 at 10:56 Comment(0)
P
1

This works for me. Tested in codeigniter 3.1.11, PHP 5.6.40 I use a virtualhost in my apache2 config in testing server.

<VirtualHost *:80>
     ServerAdmin [email protected]
     DocumentRoot (__DIR__)
     ServerName mydomain
     ##ErrorLog "logs/dummy-host2.example.com-error.log"
     ##CustomLog "logs/dummy-host2.example.com-access.log" common
     <Directory "(__DIR__)">
        Require all granted
        AllowOverride All
   </Directory>
</VirtualHost>

And /.htaccess content

    <IfModule mod_rewrite.c>
       RewriteEngine On
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteRule ^(.*)$ index.php/$1 [L] 
    </IfModule>
Pneumoconiosis answered 26/6, 2020 at 11:51 Comment(0)
R
1
  1. Create a .htaccess file in root directory (change RewriteBase by project name)

After creating the .htaccess file, add the following code to this file.

RewriteEngine On
RewriteBase /CodeigniterCURD/
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
  1. Removing index.php file (IN CONFIG.PHP FILE)

Open the config.php file in your text editor and remove index.php from here.

Change:

$config['index_page'] = "index.php";
To:
$config['index_page'] = '';

But in a few cases, it may happen that the default setting for url_protocol does not work properly. For solving this problem we need to open config.php and

Change: according to your project name

$config['base_url'] = 'http://localhost:8082/CodeIgniter/';


[![enter image description here][1]][1]


  [1]: https://i.stack.imgur.com/1Ew3Q.png
Replication answered 18/5, 2021 at 9:44 Comment(0)
M
0

Follow these step your problem will be solved

1- Download .htaccess file from here https://www.dropbox.com/s/tupcu1ctkb8pmmd/.htaccess?dl=0

2- Change the CodeIgnitor directory name on Line #5. like my directory name is abc (add your name)

3- Save .htaccess file on main directory (abc) of your codeignitor folder

4- Change uri_protocol from AUTO to PATH_INFO in Config.php file

Note: First of all you have to enable mod_rewrite from httpd.conf of apachi by removing the comments

Midweek answered 28/8, 2014 at 12:4 Comment(0)
A
0

Use this code. Change the 2nd line as you have your folder name. Where index.php file and folders application, system folder lie. Mostly problems happen due to second line. we don't configure the folder name where project is place. Important is 2nd line. This is simple to remove the index.php. RewriteEngine on RewriteBase /project_folder_name RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php/$0 [PT,L]

#RewriteEngine on
#RewriteCond $1 !^(index\.php|images|robots\.txt)
#RewriteRule ^(.*)$ index.php/$1 [L]    

Go to controller/config.php file.

config['index_url']='';

Reference for more study.

https://ellislab.com/expressionengine/user-guide/urls/remove_index.php.html

https://ellislab.com/blog/entry/fully-removing-index.php-from-urls

Akron answered 18/12, 2014 at 4:49 Comment(0)
L
0

Besides these answers, one can just, add index.php or edit it (if it is already there) - for security you want to disable index.php anyway, from listing the files in your website directory - then change the content into

<?php
   header('location:your_required_starting.php'); 
?>
Lalia answered 24/11, 2016 at 7:21 Comment(0)
K
0

Minor thing: (Optional)

Try restarting your Apache after updating the rewrite engine status in vhosts as Rewrite ON.

One critical thing to notice:

In Apache vhosts file, check whether you have this script line AllowOverride None If yes, please remove/comment this line.

My vhosts file script: (Before)

<VirtualHost *:80>
    DocumentRoot "/path/to/workspace"
    ServerName ciproject
    ErrorLog "/path/to/workspace/error.log"
    CustomLog "/path/to/workspace/access.log" common
    Directory   "/path/to/workspace">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory> 
</VirtualHost>

My vhosts file script: (After)

<VirtualHost *:80>
    DocumentRoot "/path/to/workspace"
    ServerName ciproject
    ErrorLog "/path/to/workspace/error.log"
    CustomLog "/path/to/workspace/access.log" common
    Directory   "/path/to/workspace">
        Options Indexes FollowSymLinks
        #AllowOverride None
        Order allow,deny
        Allow from all
    </Directory> 
</VirtualHost>

I faced the same problem, struggled for around 1 day, all were fine. Later, by trial and error method, found this thing. After removing this, my job was accomplished. The URL now does not look up for index.php :)

Kumler answered 5/9, 2017 at 13:26 Comment(0)
Z
0

if all the above solution not work then in your project folder their will be two files index.html and index.php, rename index.html to index_1.html and browse your project.

Zischke answered 15/3, 2018 at 15:28 Comment(0)
B
0

Note the difference with the added "?" character after ".php", especially when dealing with CodeIgniter:

RewriteRule ^(.*)$ index.php/$1 [L]

vs.

RewriteRule ^(.*)$ index.php?/$1 [L]

It depends on several other things.. if doesn't work, try the other option!

Bundy answered 10/8, 2018 at 5:28 Comment(0)
W
0

You can eliminate index.php from URL by create .htaccess file in the base directory of your porject, that file its content as

RewriteEngine on
RewriteCond $1 !^(index\.php|assets|images|js|css|uploads|favicon.png)
RewriteCond %(REQUEST_FILENAME) !-f
RewriteCond %(REQUEST_FILENAME) !-d
RewriteRule ^(.*)$ ./index.php/$1 [L]

save that file also your changed in config.php file is right

$config['index_page'] = '';

I wish to run successfully

Weatherman answered 11/1, 2019 at 17:32 Comment(0)
B
0

In CodeIgniter 3.16 in using htaccess to

remove index.php file

& also

redirect HTTP to HTTPS

Follow are the codes:

  • go to application\config\config.php file

Make changes

$config['index_page'] = 'index.php';

To

$config['index_page'] = '';
  • Now, Open the .htaccess file, and update the codes below
RewriteEngine on
RewriteBase /

## Redirect SSL
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,L]

## Remove fron url index.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond $1 !^/(index\.php|assets/|humans\.txt)
RewriteRule ^(.*)$ index.php/$1 [L] 

Brochure answered 10/11, 2019 at 6:23 Comment(0)
C
0

You have to place the .htaccess in the htdocs folder, and the part of

RewriteRule ^(.*)$ /index.php/$1 [L] 

must be written like this:

RewriteRule ^(.*)$ /your_codeigniter_project_folder/index.php/$1 [L]

Yeah I know that if you have other projects in xampp they will be messed up :(

When you upload the site to a remote server you can remove /your_codeigniter_project_folder/ from the .htaccess file contents

Conviction answered 13/10, 2021 at 3:36 Comment(0)
V
0

You can try with this it works for me

replace your htaccess file code with this

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

And also change in the config file like this

$config['index_page'] = '';
Voroshilov answered 24/6, 2022 at 12:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.