Apache 禁止访问目录,但不允许访问别名?

Apache 禁止访问目录,但不允许访问别名?,apache,.htaccess,mod-rewrite,httpd.conf,apache2.4,Apache,.htaccess,Mod Rewrite,Httpd.conf,Apache2.4,使用Apache。当/storage/是/.storage/subdomain/的别名时,如何允许访问/storage/但拒绝访问/.storage/呢 # Define alias based on subdomain RewriteCond %{HTTP_HOST} ^([^.]+)$ RewriteRule ^storage/(.*)$ ".storage/%1/$1" [QSA,L] # Forbid access to RewriteCond %{REQUEST

使用Apache。当/storage/是/.storage/subdomain/的别名时,如何允许访问/storage/但拒绝访问/.storage/呢

# Define alias based on subdomain
RewriteCond %{HTTP_HOST} ^([^.]+)$
RewriteRule ^storage/(.*)$ ".storage/%1/$1" [QSA,L]

# Forbid access to 
RewriteCond %{REQUEST_URI} ^/\.storage/
RewriteRule ^ - [F,L]

根据你们展示的样品,你们能试一下吗。请确保在测试URL之前清除浏览器缓存。我们需要先修复用于获取子域的regex,然后需要从规则中更改
,并在检查中添加附加条件,以确保用户无法直接访问实际文件夹

RewriteEngine ON
# Define alias based on subdomain
RewriteCond %{HTTP_HOST} ^(?:www\.)(.*)$ [NC]
RewriteRule ^storage/(.*)$ .storage/%1/$1 [NC,QSA,L]

# Forbid access to 
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^\.storage - [F,NC,L]