Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/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 htaccessrewritecond-f问题_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

Apache htaccessrewritecond-f问题

Apache htaccessrewritecond-f问题,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,更新:问题已解决 几个小时后,我终于明白问题出在文件夹权限上(757而不是755) 该死,我觉得自己像个白痴,但至少问题解决了:) 谢谢大家 我的.htaccess和mod_重写有一个奇怪的问题 目前,我在根目录上拥有以下.htaccess权限: Options +FollowSymLinks Options -MultiViews RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQ

更新:问题已解决
几个小时后,我终于明白问题出在文件夹权限上(757而不是755)

该死,我觉得自己像个白痴,但至少问题解决了:)

谢谢大家


我的.htaccess和mod_重写有一个奇怪的问题

目前,我在根目录上拥有以下.htaccess权限:

Options +FollowSymLinks
Options -MultiViews

RewriteEngine On

RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.php [NC,L] 
问题是:
我希望能够访问任何现有文件

即:mysite.com/anydir/myfile.png->打开anydir/myfile.png
-mysite.com/anydir/script.php->打开anydir/script.php
-mysite.com/file.png->open file.png
-mysite.com/notadir/imnotafile->重写

但是,除了第二点之外,一切都是有效的。我在我的
test
文件夹中有一个
file.php
,但是当我这样做时,它会不断重写它,它不应该

我做错了什么?

可能是因为:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
[L]
立即停止重写过程,不再应用任何规则。所以

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.php [NC,L] 
没有解释

更新2:

服务器将遵循符号链接:

Options +FollowSymLinks
服务器将禁用多视图:

Options -MultiViews
将启用重写引擎:

RewriteEngine On
重写的基本目录将是
/

RewriteBase /
如果请求与不存在的文件匹配,请继续:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
如果请求与不存在的目录匹配,请继续:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
在不敏感的情况下,重写到
index.php
,并停止执行下一个规则:

RewriteRule index.php [NC,L] 
因此,请尝试以下方法:

Options +FollowSymLinks
Options -MultiViews

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule index.php [NC,L]

如果您只是想消除404错误,可以使用

ErrorDocument 404 index.php
如果你想重写每个目录,我想你应该删除

RewriteCond %{REQUEST_FILENAME} !-d

欢迎来到堆栈溢出!(:@GabrielSantos谢谢:)我刚刚测试了你的.htaccess,没有看到这个重写。可能是缓存问题。我怀疑这是某种服务器配置@OlafDietscheIt仍然存在同样的问题:(尝试过了,仍然在重写.php文件(但所有其他类型的文件都不会被重写)@HenriqueMouta,我认为你犯了一些错误。从这里我可以直接访问文件,如果它们存在的话。因此,
dir/file.php
a/b/c/d/e.php
如果它们在正确的位置就可以工作。
RewriteCond%{REQUEST\u FILENAME}!-d
=如果请求不是现有目录,请继续。问题是:
我希望能够访问任何现有文件。
(可能包括目录)啊,耶,对不起,我被另一篇与.htaccess xD类似的帖子弄糊涂了