Apache

From Leaky
Jump to: navigation, search

IP based redirect

Apache virtualhost config to allow configuring of a Wordpress site while still redirecting the domain to some other site until Wordpress is ready.

ServerName www.example.com
ServerAlias example.com
ServerAdmin webmaster@example.com
DocumentRoot /home/example/public_html/

RewriteEngine On
# Replace 1.2.3.4 with the IP setting up the site
RewriteCond %{REMOTE_ADDR} =1.2.3.4
RewriteRule ".?" "-" [L]

# Everyone other than 1.2.3.4 gets redirected to example.wordpress.com
RewriteCond %{SERVER_NAME} =example.com [OR]
RewriteCond %{SERVER_NAME} =www.example.com
RewriteRule ^ https://example.wordpress.com%{REQUEST_URI} [NE,R=temp,L]