使用Apache。当/storage/是/.storage/的别名时,如何允许访问/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]发布于 2021-02-15 09:42:50
根据您展示的样品,您可以尝试以下内容吗?请确保在测试URL之前清除浏览器缓存。我们需要修复正则表达式获取子域,然后我们需要更改规则中的",并添加额外的条件检查,以确保用户不能直接访问实际的文件夹。
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]https://stackoverflow.com/questions/66201710
复制相似问题