Forum Moderators: phranque

Message Too Old, No Replies

strip query string from url

add rewrite code to .htaccess to strip query string off URL

         

Szone124

5:22 pm on Mar 21, 2007 (gmt 0)

10+ Year Member



There are several incoming links to my website that have query string at the end, just for tracking purposes (www.example.com/?src=ART). There are several numbers after ART like ART89 or ART91 so my code needs to strip anything with "?src=ART" after the domain name.

I have tried many times to add a little rewrite code in my .htaccess file to strip the query string and just show www.example.com, especially to bots. What would be a relatively easy way of doing that?

Thanks for the help.

jdMorgan

6:16 pm on Mar 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try this search [google.com] to get started.

Jim

Szone124

6:53 pm on Mar 21, 2007 (gmt 0)

10+ Year Member



Thanks a lot. One of the search results pointed to one of your solutions. The query string are gone

Here's what I used...
RewriteCond %{query_string} .
rewriterule (.*) http://www.example.com/$1? [R=301,L]

I assume that, because it is a 301 redirect, the search engine bots will also see my URLs without the query strings?