homepage Welcome to WebmasterWorld Guest from 54.196.207.55
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
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
kevsh




msg:3280520
 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:

[mydomain.com...]

and I want to redirect this to:

[mydomain.com...]

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!

 

jdMorgan




msg:3280614
 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]
-or-
# 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.

Jim

kevsh




msg:3280804
 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