Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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文件: RewriteEngine On RewriteBase / RewriteRule ^plugins/.* pluginLoader.php [L] RewriteRule ^settings\.php index.php [L] RewriteCond %{REQUEST_FILENAME} !-f [OR] RewriteCond %{REQUEST_FILENAME} \.art$ [OR] RewriteCond %{REQUEST_FILENAME}

我有以下
.htaccess
文件:

RewriteEngine On
RewriteBase /
RewriteRule ^plugins/.* pluginLoader.php [L]
RewriteRule ^settings\.php index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} \.art$ [OR]
RewriteCond %{REQUEST_FILENAME} /system/
RewriteRule .* index.php [L]
在URL指向位于
plugins
目录中的现有文件名(不带扩展名)之前,它是可以正常工作的。我不知道为什么。例如,有一个
/plugins/invoice/name.txt
文件

http://localhost/plugins/invoice/name.txt
   uses pluginLoader.php as expected
http://localhost/plugins/invoice/name.
   uses pluginLoader.php as expected
http://localhost/plugins/invoice/name
   uses index.php! Why?
http://localhost/plugins/invoice/nam
   uses pluginLoader.php as expected
这同样适用于扩展名为
.txt
.php
的所有文件。如果文件具有
.sql
扩展名,则它既不使用
pluginload.php
也不使用
index.php
。它发送404-未找到

有前置处理器吗

有趣的是:

RewriteEngine On
RewriteBase /
RewriteRule ^plugins/.* pluginLoader.php [L]
RewriteRule ^settings\.php index.php [L]
删除最后四行可以使其正常工作。但是URL
http://localhost/plugins/invoice/fill
仍然会出现404错误。重命名文件后,URL将正常工作


神秘…

将.htaccess代码替换为以下代码,看看是否有帮助:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^plugins/ pluginLoader.php [L,NC]

RewriteRule ^settings\.php/?$ index.php [L,NC]

RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} \.art$ [OR]
RewriteCond %{REQUEST_FILENAME} /system/
RewriteRule ^ index.php [L]

确保
$DOCUMENT\u ROOT/plugins
目录中没有.htaccess。

调试此文件的最佳方法(因为它只能针对您的系统)——启用最高级别的重写调试并分析日志(我希望您是在流量很少或没有流量的本地/dev服务器上测试此功能,否则日志文件将变得巨大且难以调试)。(对于2.4,如果您是在2.2分支上,那么)
选项-多视图
应能解决“名称冲突”问题