Table of Contents

Apache HTTP Server Configuration Examples

Apache .htaccess : How to use .htaccess on Apache



Examples

Interdiction listing

Options -Indexes 
IndexIgnore *


Deny .ht* files

<Files ~ "^\.ht">
deny from all
</Files>


Deny to other domain

OK : http://www.example.com/
NG : http://user.rental-server.com/example.com/

SetEnvIf Host "^www\.example\.com$" hos_ok
order deny,allow
deny from all
allow from env=hos_ok 


Redirect

Sample1
RewriteEngine On RewriteRule ^(.*)$ http://new.com/

http://old.com/ -> http://new.com/
http://old.com/test1.html -> http://new.com/
http://old.com/test2.html -> http://new.com/


Sample2
Redirect permanent / http://new.com/

http://old.com/ -> http://new.com/
http://old.com/test1.html -> http://new.com/test1.html
http://old.com/test2.html -> http://new.com/test2.html


Sample3
RewriteEngine On
RewriteRule  old.html$ http://new.com/dir/new.html [R=301,L]

http://old.com/old.html -> http://new.com/new.html