Forum Moderators: phranque
I am a complete newbie at mod rewrite and hope someone can set me in the right direction
Access to my site is possible through my hosts directory.
[name.myhost.co.uk...] and also through [domainname.co.uk...]
google has somehow managed to index my entire site through both and I'm worried this will be seen as a mirrored site.
Is it possible to redirect any calls to ~myname to redirect to the correct path on wwWebmasterWorldebname.co.uk as a permanent redirect so that google may eventually drop the unwanted index.
I still need access to [name.myhost.co.uk...] as I use the shared SSL
I tried a mod rewrite in the form of
RewriteRule ^~myname [domainname.co.uk...]
but it doesn't seem to pick up on the ~myname, as if this isn't reported.
Thanks for any help
David
Welcome to WebmasterWorld [webmasterworld.com]!
The "~username" part of the URL will be stripped off by the time the server passes control to your code (because your code is IN "~username").
To avoid redirecting https requests, you will need to add a RewriteCond to detect https accesses. This is usually done by checking for %{SERVER_PORT} equal to 443.
This search [google.com] may help to get you started.
Jim
You certainly saved me a lot of time.
I think the solution I wanted is:
RewriteEngine On
RewriteCond %{SERVER_PORT}!^443$
RewriteCond %{HTTP_HOST} ^name.myhost.co.uk
Rewriterule (.*) [domainname.co.uk...] [R=301,L]
Could someone please confirm this looks OK and that it won't do any harm to google.
I am hoping it Permanently redirects any request for [name.myhost.co.uk...] to www.domainname.co.uk ,unless it is a https request.
Thanks
David
It Permanently redirects any request for any page requested from http://name.myhost.co.uk/~myname to the same page at http://www.domainname.co.uk , and as such, won't redirect https requests.
As to confirming that it won't cause a problem with Google, I can't say... I can say that if it causes a problem with Google, it is because Google has a bug, or because you have already had problems with Google, and this change further confuses them. I will say that I have used this approach many, many times with no problems. Others have posted that they have had problems, but *it seems* that their problems are in addition to pre-existing problems such as PR0'ed (penalized) pages, duplicate-content penalties, etc.
All we can do is to conform to the specifications [w3.org], return the proper server codes, and hope that the search engines don't have a bug. Most of the time they don't, but occasionally they do. My lawyer made me say all that... ;)
Jim