.htaccess removing index.php from URLs
-
Hiya everyone, I've been getting quite a headache over this issue. Basically I just want to remove index.php from URLs, e.g. the URL
http://mydomain.com/index.php
should be changed tohttp://mydomain.com/
andhttp://mydomain.com/folder/index.php
should behttp://mydomain.com/folder/
. However, I also want to preserve any parameters passed to the page, e.g.http://mydomain.com/index.php?id=22&c=1
should be changed tohttp://mydomain.com/?id=22&c=1
andhttp://mydomain.com/folder/index.php?id=22&c=1
should behttp://mydomain.com/folder/?id=22&c=1
. I've triedRewriteRule ^(.*)$ /index.php?/$1 [NC]
but that just gives me an HTTP 500. Also triedRewriteRule ^index.php - [NC]
but that apparently does nothing. Help? :(( Thanks. -
Hiya everyone, I've been getting quite a headache over this issue. Basically I just want to remove index.php from URLs, e.g. the URL
http://mydomain.com/index.php
should be changed tohttp://mydomain.com/
andhttp://mydomain.com/folder/index.php
should behttp://mydomain.com/folder/
. However, I also want to preserve any parameters passed to the page, e.g.http://mydomain.com/index.php?id=22&c=1
should be changed tohttp://mydomain.com/?id=22&c=1
andhttp://mydomain.com/folder/index.php?id=22&c=1
should behttp://mydomain.com/folder/?id=22&c=1
. I've triedRewriteRule ^(.*)$ /index.php?/$1 [NC]
but that just gives me an HTTP 500. Also triedRewriteRule ^index.php - [NC]
but that apparently does nothing. Help? :(( Thanks.would adding the following line in .htaccess solve your issue? DirectoryIndex index.php or do you want the page to redirect to http://mydomain.com/ even when a user enters http://mydomain.com/index.php ?
Tech Notes on Web Development and Software Development Technology
-
would adding the following line in .htaccess solve your issue? DirectoryIndex index.php or do you want the page to redirect to http://mydomain.com/ even when a user enters http://mydomain.com/index.php ?
Tech Notes on Web Development and Software Development Technology
-
Hiya everyone, I've been getting quite a headache over this issue. Basically I just want to remove index.php from URLs, e.g. the URL
http://mydomain.com/index.php
should be changed tohttp://mydomain.com/
andhttp://mydomain.com/folder/index.php
should behttp://mydomain.com/folder/
. However, I also want to preserve any parameters passed to the page, e.g.http://mydomain.com/index.php?id=22&c=1
should be changed tohttp://mydomain.com/?id=22&c=1
andhttp://mydomain.com/folder/index.php?id=22&c=1
should behttp://mydomain.com/folder/?id=22&c=1
. I've triedRewriteRule ^(.*)$ /index.php?/$1 [NC]
but that just gives me an HTTP 500. Also triedRewriteRule ^index.php - [NC]
but that apparently does nothing. Help? :(( Thanks.You might wanna try something in the lines of
RewriteRule ^([^/?]+/)*index.php(\?.*)?$ $1 [NC,QSA,L]
. This will rewrite all the index.php to folder/?whatever. You will probably need to play with it a little as I didn't have time to thouroughly check it. :)