.htacacess 常用操作

1.301跳转

RewriteCond %{http_host} !(^www.x.com$) [NC]
RewriteRule ^(.*)$  http://www.x.com/$1 [L,R=301]
2.权限控制

# deny *everything*
<FilesMatch ".*\..*">
Order Allow,Deny
Deny from all
</FilesMatch>

# but now allow just *certain* necessary files:
<FilesMatch ".*\.(js|css|jpg|gif|png|html|pdf)$">
Order Allow,Deny
Allow from all
</FilesMatch>

你可能感兴趣的:(htacacess)