views:

41

answers:

1

Hi all,

Just wondering if someone can help me with the following issue.

I want to redirect my site to a subdomain, whishc simply displays a maintenace page, allowing me to work on the main site.

So I have the following code for my .htaccess:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.co.uk$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain.co.uk$
RewriteRule ^/?$ "http\:\/\/maintenance\.domain\.co\.uk" [R=301,L]

However, I need to access the root domain to be able to view the work that I have done; however, I only want myself on my IP to be able to view that and the outside world is redirected to the subdomain which displays the maintenace page.

I would have thought that the following code:

RewriteCond %{REMOTE_HOST} !^00\.000\.00\.000

Would have allowed me to do that; however, I'm still being redirected to the sub domain and I wondered is someone could assist me further wth this.

Thanks

A: 

You'd be better of using %{REMOTE_ADDR}, I believe:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.co\.uk$ [NC]
RewriteCond %{REMOTE_ADDR} !=00.00.00.00
RewriteRule ^/?$ http://maintenance.domain.co.uk/ [R=301,L]
Tim Stone
Hi, I have tried that and it still simply directs me to the subdomain and does not allow me to view the www.domain.co.uk. There is no issue with IP and equally I have cleared my cache.
Bill Johnson
@Bill Johnson: If you're sure that your browser isn't caching the 301 response, then I don't know what else it might be. How much control do you have over the server (or is it shared hosting)?
Tim Stone
Fixed it with:RewriteCond %{HTTP_HOST} !^maintenance\.domain\.co\.uk$ [NC]RewriteCond %{REMOTE_ADDR} !^12\.34\.56\.78$RewriteRule ^.*$ http://maintenance.domain.co.uk/ [R=301,L]
Bill Johnson