Forum Moderators: phranque

Message Too Old, No Replies

Redirect 301 putting a "?link=" on the final url

         

LucasP

6:46 pm on Feb 8, 2010 (gmt 0)

10+ Year Member



Hi there, how are you doing?

I've tried to create a simple 301 redirect but unfortunatelly something is going wrong. The redirect works fine but a curious side effects occurs: a ?link= is concatenated on the final url.

For example, I'm using this lines on my .htaccess

Redirect 301 /my-page.html http://192.168.1.22/mypage/

OR

redirectMatch 301 ^/(my-page).html$ http://192.168.1.22/$1

Both drive me to http://192.168.1.22/my-page/?link=/my-page.html

Any one known why this occurs?

Many thanks!

Lucas

[edited by: jdMorgan at 9:05 pm (utc) on Feb 8, 2010]
[edit reason] De-linked [/edit]

g1smd

7:21 pm on Feb 8, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



There are several possible reasons.

One is that you also use an internal rewrite, and the rewrite is actioned before your redirect, and this exposes the internal filepath back out as a URL.

To avoid this, change your redirect to use a RewriteRule with [R=301,L] flags, instead of using Redirect or RedirectMatch. Make sure the redirect code is listed before the rewrite code.

LucasP

8:34 pm on Feb 8, 2010 (gmt 0)

10+ Year Member



Many thanks g1smd, your solution works fine.

g1smd

9:20 pm on Feb 8, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Let's see the final code to check if there are any other problems lurking within...