homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Rewriting "?" At Beginning of URL

 12:54 pm on Mar 13, 2007 (gmt 0)

I'm at my wit's end with this one, and I've searched everywhere without help. Google has indexed my home page as:


and I want to redirect this to:


I'm not even sure how it grabbed this URL so I'm hoping to rewrite *any* numerical variable (i.e.?cat=[0-9])

The actual "home page" file is index.php if that is a factor.

Thanks in advance for any suggestions!



 2:35 pm on Mar 13, 2007 (gmt 0)

I'm not sure whether you want/need to drop the query strings from index.php as well, so here are two rules, preceded by the required "setup":

Options +FollowSymLinks -MultiViews
RewriteEngine on
# Remove any query string from "/"
RewriteCond %{QUERY_STRING} .
RewriteRule ^$ http://www.example.com? [R=301,L]
# Remove any query string from "/" or "index.php"
RewriteCond %{QUERY_STRING} .
RewriteRule ^(index\.php)?$ http://www.example.com? [R=301,L]

If you have other working rewriterules, then you may not need the "setup" stuff. However, if you don't have a working knowledge of mod_rewrite, I strongly suggest you review the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com] before trying to use this code.



 5:27 pm on Mar 13, 2007 (gmt 0)

The first example worked fine, thanks!

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved