nac*_*ito 34
.htaccess指令适用于该目录及其所有子目录,因此您应禁止在DocumentRoot中访问,
http://sub.mydomain.com/.htaccess:
Order deny,allow
Deny from all
Run Code Online (Sandbox Code Playgroud)
并在您希望允许访问的任何特定子目录中覆盖它,
http://sub.mydomain.com/test/.htaccess:
Order allow,deny
Allow from all
Run Code Online (Sandbox Code Playgroud)
如何在根目录下使用.htaccess,并使用以下行?
RewriteEngine On
# check if request is for subdomain
RewriteCond %{HTTP_HOST} ^sub.mydomain.com$ [NC]
# check if 'test' isnt part of request
RewriteCond %{REQUEST_URI} !^/test/?(.*)$ [NC]
# if subdomain and no 'test' part, redirect to main domain...
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R,L]
Run Code Online (Sandbox Code Playgroud)
因此,如果'/ test /'部分存在,则不会发生重定向...
归档时间: |
|
查看次数: |
36993 次 |
最近记录: |