Forum Moderators: phranque

Message Too Old, No Replies

301 redirect without passing variables

         

Samjam

3:36 pm on Mar 18, 2008 (gmt 0)

10+ Year Member



With all kinds of 301 redirects i found, all parameters at the end of the url are passed to the new domain, which creates lots of duplicate content, as the parameters are no longer needed:
for example:

Redirect 301 / http://www.example.com/

causes: http://www.example.com?var=1
to redirect to: http://www.example.com/?var=1

but i want it to redirect to http://www.example.com/

The only thing i found in hours of searching is this:

Redirect 301 / http://www.example.com/?

which removes all parameters, but leaves the ? at the end, which isn't really clean either, and i suppose counts as duplicate content too.

Any help is greatly appreciated! =)

Samjam

[edited by: jdMorgan at 4:32 pm (utc) on Mar. 18, 2008]
[edit reason] example.com [/edit]

jdMorgan

4:31 pm on Mar 18, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Use mod_rewrite rather than mod_alias. By appending a "?" to the substitution URL, the query string is removed, but the "?" itself will not appear in the redirected-to URL.

Jim

Samjam

5:19 pm on Mar 18, 2008 (gmt 0)

10+ Year Member



Wow, that really worked! Thank you so much jdMorgan! =)

Thats the code i now use, for anyone interrested:

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.example.com/? [R=301,L]