Forum Moderators: phranque

Message Too Old, No Replies

Get rid of query strings?

redirects, query strings

         

Cromagnon

9:19 am on Feb 8, 2008 (gmt 0)

10+ Year Member



Hí all,

I am really an idiot when it comes to redirects.. ;-)

I am trying to get rid of all query strings in my URLs - like this:

www.example.com/topic.htm?ref=another-eaxmple.org

First I tried to simple do a htaccess like this:

User-agent: *
Disallow: /*?

But that does not seems to work. Then I read this thread:

[webmasterworld.com...]

And did it like this:

RewriteCond %{QUERY_STRING} .
RewriteRule (.*) http://www.example.com/$1? [R=301,L]

But nothing happend.

I like www.example.com/topic.htm?ref=another-eaxmple.org to be redirected to www.example.com/topic.htm and www.example.com/?ref=another-eaxmple.org to be redirected to www.example.com

Anyone has any ideas why this is not working?

Thanks

phranque

10:24 am on Feb 8, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



do you have something like this in your .htaccess (which would enable mod_rewrite)?

Options +FollowSymLinks
RewriteEngine on

Cromagnon

1:48 pm on Feb 8, 2008 (gmt 0)

10+ Year Member



Nope, at the moment I only have:

RewriteCond %{QUERY_STRING} .
RewriteRule (.*) http://www.example.com/$1? [R=301,L]

in my htaccess. Wich is not working

phranque

2:57 pm on Feb 8, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



you might try this then:

Options +FollowSymLinks
RewriteEngine on

RewriteCond %{QUERY_STRING} .
RewriteRule (.*) http://www.example.com/$1? [R=301,L]

g1smd

10:54 pm on Feb 8, 2008 (gmt 0)

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



That should work OK, as long as the server does run Apache.

jdMorgan

12:39 am on Feb 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



... and as long as the browser cache is completely flushed before testing any new code.

Jim

phranque

2:13 am on Feb 9, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



as long as the server does run Apache

i think the OP mention of htaccess and posting in this forum lets you assume apache.

g1smd

7:18 pm on Feb 9, 2008 (gmt 0)

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



ass-u-me

Been there. Done that. :-)