我在Laravel中有应用程序,还有我要排除的public_html中的另一个文件夹 来自Laravel的重定向。
例如在public_html中我有文件夹staff /
我想排除该文件夹中所有文件和文件夹的重定向,以便有人试图访问
domain.com/staff/index.php或domain.com/staff/folder1/实际查看该目录。
现在我的htaccess是这样的:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Exclude directory from rewriting
RewriteRule ^(staff) - [L]
# Redirect Trailing Slashes
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
这适用于domain.com/staff它实际上在staff /而不是根目录中的laravel index.php中打开index.php。但如果我去/ staff / folder /它使用Laravel。
如何从laravel路由器中删除包含所有子文件夹和文件的目录?
答案 0 :(得分:1)
您可以使用正则表达式来匹配与staff
完全匹配或以staff/
开头的请求,如下所示:
RewriteRule ^staff($|/) - [L]