Redirect med htaccess

Redirect af besøgende til en specifik side, med undtagelse af specifikke IP-adresser.

Du finder din ip-adresse ved fx at bruge Google: what is my ip

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# BEGIN redirect
RewriteEngine on
# home
RewriteCond %{REMOTE_ADDR} !^192\.198\.0\.1
# work
RewriteCond %{REMOTE_ADDR} !^192\.198\.0\.2
RewriteCond %{HTTP_HOST} ^domain.dk$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain.dke$
RewriteRule ^(.*)$ http://domain.dk/midlertidig-side/$1 [R=307,L]
# END redirect

301 – permanent redirect
307 – midlertidig redirect (det samme som 302)

Leave a Reply

Your email address will not be published. Required fields are marked *