Forum Moderators: phranque

Message Too Old, No Replies

301 Redirect Adding Old URL At The End?

         

rhwd2003

4:50 pm on Jan 25, 2011 (gmt 0)

10+ Year Member



So I am trying to do a 301 redirect that should be working like this:

OLD URL: www.mydomain.com/test/an-old-url.html

301'ed to: www.mydomain.com/new/

But it looks like this after the 301:
www.mydomain.com/new/?url=an-old-url.html

I am not just redirecting that one url I have about 400 others that are in all different sub-directories so its not just /test/ its /test1/, /test2/...etc and going to /new1/, /new2/...etc

Here is what I think is controlling it in apache:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^mydomain.com [NC]
RewriteRule ^(.*)$ [mydomain.com...] [L,R=301]

Does anyone know what would be causing this and how to fix it?

P.S. I also found this in the .htaccess but don't really know if it effects this or not.

RewriteRule ^content/([0-9]+)\-.+ content/index.php?id=$1
RewriteRule ^finance/([0-9]+)\-.+ finance/index.php?id=$1
RewriteCond %{REQUEST_URI} ^(/component/option,com) [NC,OR] ##optional - see notes##
RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|/[^.]*)$ [NC]
RewriteCond %{REQUEST_URI} !^/forums/ [NC]
RewriteCond %{REQUEST_URI} !^/content/
RewriteCond %{REQUEST_URI} !^/dfa/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php

jdMorgan

7:33 pm on Jan 31, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In general, go through your .htaccess files, and be sure that all external redirects are executed before any internal rewrites. That is, rules which specify a protocol and domain name in the substitution, or which include the [R=30x] flags must be executed first.

Specifically, based on your example above, you are looking for a rule where the substitution contains "?url=$1" or "?url=%2" where the $1 or %2 is a back-reference to the requested URL-path. This rule is being executed *before* an external redirect (which breaks the general rule just described) and the effect is that this script query-string is therefore being exposed to the client as a URL.

Jim