Forum Moderators: phranque

Message Too Old, No Replies

Rewrite rule help needed for mirrored site

         

Davjack

10:22 pm on Apr 6, 2004 (gmt 0)

10+ Year Member



Hi all

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

jdMorgan

12:38 am on Apr 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Davjack,

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

Davjack

8:08 pm on Apr 7, 2004 (gmt 0)

10+ Year Member



Thanks 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

jdMorgan

8:37 pm on Apr 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> it Permanently redirects any request for http://name.myhost.co.uk/~myname to www.domainname.co.uk ,unless it is a https request.

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

Davjack

9:07 pm on Apr 7, 2004 (gmt 0)

10+ Year Member



Thanks Jim

Thats exactly the answer I was hoping for.
I have tried it live and everything seems to be working as desired. Just hope the spiders like it too.

Thanks again for the excellent responses.

David