homepage Welcome to WebmasterWorld Guest from 54.197.215.146
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

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

Apache Web Server Forum

    
"300 Multiple Choices" problem after domain 301 redirect
herculano




msg:4424384
 1:43 am on Mar 3, 2012 (gmt 0)

Hi guys,

I've been searching everywhere online but couldn't find a similar problem I'm having. I hope there's someone who can help, I did a 301 redirect from my old domain to my new domain via htaccess, after a few weeks I started seeing multiple "300 multiple choices" results for my old domain in google search result:

300 Multiple Choices
www.olddomain.com/index.php%3Fcode%3DABC123
Multiple Choices. The document name you requested ( /index.php?code=ABC123 ) could not be found on this server. However, we found documents with names ...

My hunch is since I'm not a pro in htaccess 301 redirect configuration I might have done something wrong with it. However page rank seems to have moved over to the new domain, even for those that have the 300 Multiple Choices problem, but the traffic for the entire site is still about 8-10% of what it used to be, it's been about 40-45 days now, not sure if the 300 Multiple Choices problem is causing it not to get the original amount of traffic.

htaccess looks like this:

RewriteEngine on

RewriteCond %{HTTP_HOST} !^www\.newdomain\.com [NC]
RewriteCond %{HTTP_HOST} ^newdomain\.com [NC]
RewriteRule ^(.*) http://www.newdomain.com/$1 [L,R=301]

RewriteCond %{REQUEST_URI} !^/google111111111111.html$ [NC]
RewriteCond %{HTTP_HOST} ^www\.olddomain\.com [NC]
RewriteRule ^(.*) http://www.newdomain.com/$1 [L,R=301]


Both domains are pointing to the same directory.
best regards,
Herculano

 

lucy24




msg:4424401
 4:06 am on Mar 3, 2012 (gmt 0)

:: peering into crystal ball ::

Your problem is with query strings, not the URL itself.

Aw, heck, lemme just paste in the boilerplate. Haven't brought it out in a few weeks. Read slowly.


Query Strings

The Query String, also known as a Parameter, is the part of an url after the question mark. Question = query.

By default, rewrites simply ignore the query string. That is, mod_rewrite stashes the query in a safe place, does its stuff to the part before the question mark, and then reappends the original query.

Changing a Query

#1 To delete a query, add a ? to the end of your rewrite target.
#2 To replace a query—or create a new one—add ?blahblah to the rewrite target. The blahblah can be either literal text, or stuff you captured earlier. (#1 and #2 are really the same thing: you're just replacing the query with either something or nothing.)
#3 To add to an existing query, again put ?blahblah at the end of the target, but also add [QSA] to your flags (the bracketed items at the end of the Rule). It stands for "Query String Append", meaning that the blahblah is to be added to the existing query—if any—instead of replacing it.

Getting the Query

You only need to retrieve the original query if
#1 you want the rewrite to behave differently depending on what the query was
or
#2 you need to change or delete the query

Add a Condition that says

RewriteCond %{QUERY_STRING} blahblah

using your ordinary Regular Expressions, anchors and ! as needed.

To test whether there was a query at all

RewriteCond %{QUERY_STRING} .

which simply means "If the query contains at least one character of any kind".

If you need to capture any of the query, use parentheses as usual. In the rewrite target, the captures will be %1, %2 etc instead of $1, $2 etc, because they are coming from a Condition instead of the Rule. Each set is separately numbered, so the first capture from the Rule will still be $1.


g1smd




msg:4424419
 6:52 am on Mar 3, 2012 (gmt 0)

Your entire 7 lines of code simplifies to this:

RewriteEngine on

RewriteCond %{HTTP_HOST} !^(www\.newdomain\.com)?$
RewriteCond %{REQUEST_URI} !^/google111111111111.html$ [NC]
RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]


The new code also redirects non-canonical requests such as those for
www.newdomain.com:80 etc which the original code did not.
herculano




msg:4424421
 7:18 am on Mar 3, 2012 (gmt 0)

thanks for the comments, I actually want to retain all urls as recommended by google, to retain all structure, urls even website template etc until the 301 redirect is complete.

from what i can see somewhere either by my htaccess or somewhere a url encode took place which change my ? to %3F and the = to %3D and when google uses the url to access my old site, my site returns a 300 Multiple Choice error code.

the weird thing is I only found one instance of this problem with my new domain, but several instances for my old domain.

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