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

#1
[eluser]omx[/eluser]
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)

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

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

http://localhost/CodeIgniter/index.php/welcome

Any ideas?

Cheers!

#2
[eluser]n0xie[/eluser]
Try to add this and see if this makes a difference
Code:
RewriteBase /CodeIgniter/

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

#3
[eluser]omx[/eluser]
Added that line and apache won't even start...

#4
[eluser]danmontgomery[/eluser]
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

Code:
<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]
</IfModule>

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

Code:
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".

#5
[eluser]omx[/eluser]
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?

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

So I end up with

http://localhost/welcome

instead of

http://localhost/CodeIgniter/welcome

Thanks!

#6
[eluser]bretticus[/eluser]
Code:
RewriteBase /CodeIgniter/

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

Code:
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-2020 MyBB Group.