permanent (301) redirect
redirect all pages to the root or one page of a new domain
1 2 3 4 |
RewriteEngine on RewriteCond %{http_host} ^www.domain.tld [NC,OR] RewriteCond %{http_host} ^domain.tld [NC] RewriteRule ^(.*)$ http://www.new-domain.tld/ [R=301,NC,L] |
redirect one file:
1 |
Redirect 301 /file_1 /file_2 |
redirect subdomain to the root domain keeping the url
1 2 |
RewriteCond %{HTTP_HOST} ^(www\.)?sub\.domain\.tld$ [NC] RewriteRule ^ http://www.domain.tld%{REQUEST_URI} [NE,R=301,L] |
redirect subdomain to the root domain without keeping the url
1 2 |
RewriteCond %{HTTP_HOST} ^(www\.)?sub\.domain\.tld$ [NC] RewriteRule ^ http://www.domain.tld [NE,R=301,L] |
block / disable directory indexing
1 |
Options -Indexes |
allow access to only one IP
1 2 3 |
order deny,allow deny from all allow from 111.222.333.444 |
custom message for 403 access denied
1 |
ErrorDocument 403 "you shouldn't be here |