| Welcome to WebmasterWorld Guest from 18.104.22.168 |
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
|Become a Pro Member|
|index.php to index.html and remove query string|
? still appears
| 9:44 am on Mar 11, 2009 (gmt 0)|
I used to have a index.php file under wordpress in my root directory which of course generates queries for "next pages" and the like, such as:
I want to redirect all cases of index.php to index.html or rather just the example.com as I don't use index.php any longer.
I have the following code in my .htaccess file:
Redirect 301 /index.php http://www.example.com/?
Which does the trick except it leaves the "?" at the end. if I remove the "?" at the end the complete query string is shown, ie: example.com/?c=81&s=11
Any ideas? Thanks.
| 9:47 am on Mar 11, 2009 (gmt 0)|
You have to move to mod_rewrite (unfortunately) since mod_alias does not provide this feature.
| 11:54 am on Mar 11, 2009 (gmt 0)|
Thanks - do you know the mod_rewrite code for such a situation?
| 12:09 pm on Mar 11, 2009 (gmt 0)|
If you're on Apache 2.+ you could use
RewriteRule ^index\.(?:html¦php)$ /? [R=301,L,NS]
Edit: BTW: you'll have to replace the ¦ pipe with a solid one from your keyboard since this character is modified by the forum software.
[edited by: Caterham at 12:13 pm (utc) on Mar. 11, 2009]
| 12:16 pm on Mar 11, 2009 (gmt 0)|
Wow - brilliant - that worked a treat.
Thanks very much for your time and help.
| 7:27 pm on Mar 11, 2009 (gmt 0)|
I would always also include the domain name in the redirect target URL so that both incoming non-www and www requests are fixed to the canonical form of your choosing.
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved