首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Apache,重写和.htaccess误判

Apache,重写和.htaccess误判
EN

Stack Overflow用户
提问于 2012-05-30 08:17:35
回答 1查看 244关注 0票数 0

我跟踪.htaccess文件:

代码语言:javascript
复制
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文件。

代码语言:javascript
复制
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扩展名,它既不使用pluginLoader.php也不使用index.php。它发送404 -没有找到。

有预处理器吗?

有趣的是:

代码语言:javascript
复制
RewriteEngine On
RewriteBase /
RewriteRule ^plugins/.* pluginLoader.php [L]
RewriteRule ^settings\.php index.php [L]

删除最后四行使其正常工作。但是URL http://localhost/plugins/invoice/fill仍然得到一个404错误。当文件被重命名时,URL可以工作。

神秘..。

EN

回答 1

Stack Overflow用户

发布于 2012-05-30 16:49:10

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

代码语言:javascript
复制
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]

确保在.htaccess目录中没有$DOCUMENT_ROOT/plugins

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10812474

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档