Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.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 - Fatal编程技术网

Apache 排除在.htaccess中重定向的目录

Apache 排除在.htaccess中重定向的目录,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,好的,那么我们在错误的目录中工作,嗯 我们有一个.htaccess文件,用于将一些文件重定向到PHP脚本。现在我们正在添加一些硬文件,希望绕过此重定向。到目前为止,这似乎不起作用,我们被难住了 以下是启动引擎后我们的初始.htaccess文件内容,该引擎已在为另一个应用程序工作: RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico) RewriteRule ^(.*)$ /index.php/$1 [L] 我们现在正试图从/direct

好的,那么我们在错误的目录中工作,嗯

我们有一个
.htaccess
文件,用于将一些文件重定向到PHP脚本。现在我们正在添加一些硬文件,希望绕过此重定向。到目前为止,这似乎不起作用,我们被难住了

以下是启动引擎后我们的初始
.htaccess
文件内容,该引擎已在为另一个应用程序工作:

RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico)

RewriteRule ^(.*)$ /index.php/$1 [L]
我们现在正试图从
/directory/
加载文件,因此我们已尝试将每个文件添加到
RewriteCond
部分:

RewriteCond %{REQUEST_URI} !directory

RewriteCond $1 !^(index\.php|i/|robots\.txt|favicon\.ico|directory)
两者似乎都不起作用。有没有关于如何加载的想法

示例:

应重定向

  • http://example.com/thisredirects/
不应重定向

  • http://example.com/directory

  • http://example.com/directory/

  • http://example.com/directory/index.php

  • 等等


您是否尝试在/directory目录中创建第二个.htaccess文件并在其中执行NoRewrite操作?

尝试以下操作:

不会重定向

RewriteRule directory/.* - [L]
重定向

RewriteRule ^$ thisredirects/ [L]
RewriteRule (.*) thisredirects/$1 [L]

似乎您希望将docroot中实际上不是现有文件的任何内容重定向到index.php。这一点重写应该可以处理:

RewriteCond %{REQUEST_FILENAME} -s [OR]  # file with size
RewriteCond %{REQUEST_FILENAME} -l [OR]  # file is a link
RewriteCond %{REQUEST_FILENAME} -d       # file is a directory
RewriteRule ^.*$ - [NC,L]                # don't rewrite [last rule]
RewriteRule ^(.*)$ /index.php/$1 [NC,L]       # everything else gets sent to index.php
[或]
运算符也可能是您在“重写秒”中要查找的运算符

此外,如果您只想将/directory部分列入白名单,则可以在重定向之前放置一条规则,该规则标记为“last Rule”(最后一条规则)

“执行NoRewrite”-只需禁用(甚至启用)子目录中的重写引擎就足够了。例如,
重写发动机关闭
RewriteRule ^/directory.*$ - [NC,L]