Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/hadoop/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache Htaccess重定向排除子文件夹_Apache_.htaccess_Mod Rewrite_Redirect_Laravel - Fatal编程技术网

Apache Htaccess重定向排除子文件夹

Apache Htaccess重定向排除子文件夹,apache,.htaccess,mod-rewrite,redirect,laravel,Apache,.htaccess,Mod Rewrite,Redirect,Laravel,我有一个在Laravel中的应用程序,还有一个在public_html中的文件夹,我想排除它 来自拉威尔的重定向 例如,在public_html中,我有文件夹工作人员/ 我想排除该文件夹中所有文件和文件夹的重定向,以便如果有人尝试访问 domain.com/staff/index.php或domain.com/staff/folder1/to实际查看该目录 目前,我的htaccess是这样的: <IfModule mod_rewrite.c> <IfModule mod_neg

我有一个在Laravel中的应用程序,还有一个在public_html中的文件夹,我想排除它 来自拉威尔的重定向

例如,在public_html中,我有文件夹工作人员/

我想排除该文件夹中所有文件和文件夹的重定向,以便如果有人尝试访问

domain.com/staff/index.php或domain.com/staff/folder1/to实际查看该目录

目前,我的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>
RewriteRule ^staff($|/) - [L]

选项-多视图
重新启动发动机
#从重写中排除目录
(职员)--[L]
#重定向尾部斜杠
重写规则^(.*)/$/$1[L,R=301]
#手柄前控制器
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^index.php[L]
这适用于domain.com/staff,它实际上是在staff/中打开index.php,而不是在根目录中打开laravel index.php。但是,如果我转到/staff/folder/它使用的是Laravel,那么就使用这个


如何从laravel router中排除包含所有子文件夹和文件的目录?

您可以使用正则表达式匹配与
staff
完全匹配或以
staff/
开头的请求,如下所示:

<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>
RewriteRule ^staff($|/) - [L]

您可以使用始终返回false:P的自定义筛选器向staff添加路由。或者,如果您只想排除子文件夹,请使用false自定义筛选器为staff/{whatever}添加路由
staff
目录中是否有htaccess文件?这很有趣。
RewriteCond%{REQUEST\u FILENAME}-d
重写cond%{REQUEST_FILENAME}-如果该文件/文件夹已经存在,f
应该已经阻止重定向到Laravel,不是吗?