我如何拒绝访问http://sub.mydomain.com/ ,但(完全)允许http://sub.mydomain.com/test (或http://sub.mydomain.com/test/ )
在http://sub.mydomain.com/test/后面有一个magento后端
.htaccess指令适用于该目录及其所有子目录 ,因此您应该禁止访问您的DocumentRoot,
http://sub.mydomain.com/.htaccess :
Order deny,allow Deny from all
并覆盖您想要允许访问的任何特定子目录中,
http://sub.mydomain.com/test/.htaccess :
Order allow,deny Allow from all
如何在根目录下的.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]
所以如果'/ test /'部分存在,就不会发生重定向
尝试在sub.mydomain.com中为deny创建.htaccess文件,并在sub.mydomain.com/test中允许。