Forum Moderators: phranque
www.mysite.com/
however, im getting duplicates of my index page from referrals, such as:
www.mysite.com/?source=granitecitytool
www.mysite.com/?referral=whoever
I would like to 301 redirect any request for www.mydomain.com/?(whatever here) to www.mydomain.com to avoid these duplicates. i am terrible with htaccess and need some help with this.
my other similar situation is i have a couple pages indexed twice, like
www.mysite.com/page1.html AND
www.mysite.com/page1.html?=
How could i make any page that ends in?= redirect permanently to the same url without the?=
thank you so much in advance!
Like this:
RewriteCond %{QUERY_STRING} .
RewriteRule (.*) http://www.example.com/$1? [R=301,L]
I also recommend visiting the Apache Library [webmasterworld.com] and Forum Charter [webmasterworld.com] for more information on mod_rewrite.
Hope this helps.
Justin
a permanent redirect for any page ending in?= back to the page without that extension, for example
www.mysite.com/page1.html?= permanently redirected to:
www.mysite.com/page1.html
any help GREATLY appreciated!
i used the code above:
RewriteCond %{QUERY_STRING} .
RewriteRule (.*) http://www.example.com/$1? [R=301,L]
and it was interfering with my cod to tranform dynamic into static pages. however, it would work IF it identified only pages that end in?= and not any query on the end. how could i modify this for that condition only, so it wouldnt change pages for example ending in .html?product=12, but only .html?=.
thanks in advance!
Note: this did solve my referral problem above, and would work for that if the above code was only limited to the domain with any query at the end, but not any page within the domain..
how could i modify this for that condition only, so it wouldnt change pages for example ending in .html?product=12, but only ".html?="?
RewriteCond %{QUERY_STRING} ^=$
RewriteRule ^(.+\.html)$ http://www.example.com/$1? [R=301,L]
this did solve my referral problem above, and would work for that if the above code was only limited to the domain with any query at the end, but not any page within the domain.
You can pretty much do whatever you want with rewrites, but you must very precisely define the problem first -- Which kinds of URLs you do you want to rewrite, and which ones you don't. So are you looking for a second rule in addition to the modified one above?
...limited to the domain with any query at the end, but not any page within the domain.
RewriteCond %{QUERY_STRING} .
RewriteRule ^$ http://www.example.com/? [R=301,L]
Jim
RewriteCond %{THE_REQUEST} \?.*\ HTTP/ [NC]
RewriteRule (.*) http://www.example.com/$1? [R=301,L]
I use this on most of my dynamic sites, so helpful webmasters cannot create new pages for me...
EG
/page.php?OK=1&to-duplicate-content-I'll-add-another-parameter-and-link-it=hosed
You could probably adjust the Rule/Cond for efficiency.
Justin