Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.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 URL如果不工作,则重写到子文件夹/mantisbt/不工作_Apache_.htaccess_Mod Rewrite_Redirect - Fatal编程技术网

Apache htaccess URL如果不工作,则重写到子文件夹/mantisbt/不工作

Apache htaccess URL如果不工作,则重写到子文件夹/mantisbt/不工作,apache,.htaccess,mod-rewrite,redirect,Apache,.htaccess,Mod Rewrite,Redirect,我正在尝试让htaccess执行以下操作 将所有请求从site.com/重定向到subdir'subdir',除非请求uri以/mantisbt开头/ 我使用了这个答案()中的以下代码,并添加了一个条件(第4行),但它没有得到遵守 RewriteEngine on RewriteCond %{HTTP_HOST} ^(www.)?site.com$ RewriteCond %{REQUEST_URI} !^/subdir/ RewriteCond %{REQUEST_URI} !^/mantis

我正在尝试让htaccess执行以下操作

将所有请求从site.com/重定向到subdir'subdir',除非请求uri以/mantisbt开头/

我使用了这个答案()中的以下代码,并添加了一个条件(第4行),但它没有得到遵守

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?site.com$
RewriteCond %{REQUEST_URI} !^/subdir/
RewriteCond %{REQUEST_URI} !^/mantisbt/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /subdir/$1
RewriteCond %{HTTP_HOST} ^(www.)?site.com$
RewriteRule ^(/)?$ subdir/index.php [L]
我想提到的是,在subdir/.htaccess中,我需要htpasswd user,当我访问site.com/mantisbt/which时,它会要求我提供有效的user/pass(不是标准的mantisbt登录,一种受浏览器目录保护的访问)。如果我删除了所有重写规则和条件,那么site.com/mantisbt/whaterver会按预期工作,当然,site.com/?根/子目录中的文件不提供服务

我希望我的问题是明确的,请要求更多的信息,如果必要的


谢谢您的帮助,

您可能想在第一条规则的末尾添加一个
[L]
,但对我来说效果很好。谢谢Jon,我会尝试一下,然后再告诉您。我仍然有这个问题。我将能够解除密码保护的目录很快,所以我想我会放弃修复的想法。