Bill Johnson
Bill Johnson

Reputation: 303

.htaccess redirect

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

Upvotes: 0

Views: 134

Answers (1)

Tim Stone
Tim Stone

Reputation: 19169

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]

Upvotes: 1

Related Questions