Forum Moderators: phranque
What Im trying to do is I have a client who has several domain names all with the same content. Knowing google will hate this I want to redirect all the domains to the same (main) domain.
I thought about using a 302 redirect to do this but some other sites have already linked to one of the non-main URL's in the form:
www.some-widgets.com/index.php?bla=24
or
www.someother-widgets.com/index.php?bla=2348
but I want either one of those to be redirected to:
www.widgets.com/$querystring
Hope that made some sense, sorry if it didnt!
Thanks so much for the help!
Kevin
Try searching using WebmasterWorld site search (link at top of page) for "301 domain redirect" plus your server name, e.g. Apache, IIS, etc. We've had many threads on this that will help you to define and narrow - or even answer - your question. But the methods available all depend on your server type.
Jim
I did some reading and some said that a 301 redirect would keep the query string but I tested it and it didnt seem to.
It would the page so if I had it redirect from www.some-widgets.com/about.html it would in fact take me to www.widgets.com/about.html
but if I had www.some-widgets.com/index.php?widget=13132
it would just take me to www.widgets.com/index.php
Maybe I did something wrong but dont see how...
Let me know please!
Thanks,
Kevin
Using mod_rewrite, you can preserve the query string.
In .htaccess, using:
RewriteCond %{HTTP_HOST} !^www\.maindomain\.com
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)$ http://www.maindomain.com/$1?%1 [R=301,L]
If your domains are hosted on separate virtual servers, the same thing will work, but you can/should delete the first RewriteCond.
Ref: Introduction to mod_rewrite [webmasterworld.com]
HTH,
Jim