• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
remove index.php from urls using apache httpd.conf

Hi, have viewed the wiki and after extensive googling I still can't get this to work...

Have inserted the following into my httpd.conf file (and yes mod_rewrite.so is enabled)

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^(/index\.php|/img|/js|/css|/robots\.txt|/favicon\.ico)
RewriteRule ^(.*)$ /index.php/$1 [L]

With this enabled I get a 404 when I point to:


Any ideas?


Try to add this and see if this makes a difference
RewriteBase /CodeIgniter/

Also take a look here: http://codeigniter.com/wiki/mod_rewrite/

Added that line and apache won't even start...

To expand on what n0xie said, you also need to remove the leading slash from index.php. You also should get rid of all of the /s in your RewriteCond line

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /CodeIgniter/
RewriteCond %{REQUEST_URI} !^(index\.php|img|js|css|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ index.php/$1 [L]

Depending on your host you may also need to add a ?:

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

If apache won't start it's giving an error, to know that error would be much more useful then "it won't start".

Ok, in the end I just enabled .htaccess files to override conf and got it to work.

Tried several permutations, how can I remove the CodeIgniter bit from the url?

RewriteRule ^(.*)$ /CodeIgniter/index.php?/$1 [L]
has no effect...

So I end up with


instead of



RewriteBase /CodeIgniter/

Depends on where your htaccess file is located. You should be able to use:

RewriteBase /

if your htaccess file is in the CodeIgniter folder.

If you have access to your apache config files (httpd.conf) then use virtualhosts and directory apache directives to specify exactly which directory (folder) the rewrite base refers to (plus it's much faster for apache.)

Oh, and make sure that you have mod_rewrite enabled (reason for the error perhaps.) You can check with a simple phpinfo() call (look for apache2handler.)

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.