Welcome to WebmasterWorld Guest from 50.19.53.104

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Rewrite Question

301 to a new URL handling query strings

     

SEOMike

6:18 pm on Feb 10, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A client is changing URLs and redesigning their site. Their current site has awful query strings which dynamically build every page. (ie. index.php?option=com_content&task=view&id=XX&Itemid=YY) Redirecting these pages will be a pain, but I can handle that.

My real question is how do I redirect index.php (the main page of the site with inbound links) to index.htm while ignoring index.php with a query string attached? My limited understanding of this has me thinking that anytime the redirect sees index.php in any form (with or without the query string) it'll redirect to index.php's target (the new homepage).

I'm worried it'll work like this:

301 redirect index.php -> index.htm

301 redirect index.php?awful_QS -> index.htm


I need it to work like this:

301 redirect index.php -> index.htm

301 redirect index.php?awful_QS -> matching_new_page.htm

g1smd

6:56 pm on Feb 10, 2011 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



This code will trigger for a blank query string:

RewriteCond %{QUERY_STRING} !.


and goes before the
RewriteRule
that performs the redirect.

However, I would caution against redirecting to a named index page.

You should instead redirect to
www.example.com/
with a trailing slash. Your redirect should look something like this:

RewriteRule ^index\.(php|html?) http://www.example.com/ [R=301,L]


Use this code to serve the index.html file when the "/" URL is requested:

DirectoryIndex index.htm

SEOMike

9:01 pm on Feb 10, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Great. Thanks!
 

Featured Threads

Hot Threads This Week

Hot Threads This Month