cmdref.net - Cheat Sheet and Example

cmdref.net is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools


Sidebar








Cloud



Etc


Reference














.

middleware:web:httpd:htaccess.html



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







middleware/web/httpd/htaccess.html.txt ยท Last modified: 2020/07/31 by admin

Page Tools