Forum Moderators: phranque

Message Too Old, No Replies

redirection problem

apache redirect works in most cases, but not all

         

Philiboy

11:28 pm on Nov 18, 2010 (gmt 0)

10+ Year Member



Can anyone help with the following apache redirection problem?

The following lines redirect anything that is not www.whatever.co.uk (optionally followed by a query string) to www.whatever.co.uk (keeping the query string), except that it does not work for dev.whatever.co.uk

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.whatever\.co\.uk [NC]
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(.*)$ [whatever.co.uk...] [R=301,L]

If anyone can throw any light on why it is not redirecting dev.whatever.co.uk, it would be greatly appreciated.

g1smd

12:13 am on Nov 19, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Is this .htaccess rule logically located in the file found at dev.example.co.uk/.htaccess ?

If not, that's why.

Philiboy

8:33 am on Nov 19, 2010 (gmt 0)

10+ Year Member



You are right g1smd - thanks. But now I have the following problem. He has s subfolder called subdomains and in there has a link called dev. The latter link links back to the web root. Where do I create the .htaccess file specific to dev? Or can I make an update to the robots file to get the search engines to not crawl dev? If the latter, then the dev robots file would have to be the robots file in the web root, and I don't know what to write there.

Philiboy

8:44 am on Nov 19, 2010 (gmt 0)

10+ Year Member



Is it correct that I can solve this by placing following lines in the robots file?

User-agent: *
Disallow: /subdomains/

Or is it

User-agent: *
Disallow: /dev/

Or neither? I guess I could disallow dev and subdomains to be on the safe side.

Philiboy

1:26 pm on Nov 19, 2010 (gmt 0)

10+ Year Member



Please forget my last two posts. The link does not link back to the webroot. This would not make sense anyway. I can create dev.example.co.uk/.htaccess and also place a robots file there. Problem solved.