htaccess url重写规则与文件夹名称冲突

时间:2012-03-09 18:40:22

标签: .htaccess url-rewriting

我有以下htaccess:

Options +FollowSymlinks
RewriteEngine on

RewriteRule ^models$  index.php [L]
RewriteRule ^post$  index.php?action=post [L]

以及名为models的文件夹。

问题是:Apache将我发送到该文件夹​​。使用“发布”时,重定向规则可以正常工作,因为没有名为post的文件夹。

编辑:
我忘了告诉模块文件夹中还有htaccess,其中包含:

Deny from all

2 个答案:

答案 0 :(得分:1)

如果你能接受模型之后的斜杠,我认为这样可行。

RewriteEngine On

RewriteRule ^models/?$ index.php [L]
RewriteRule ^post$ index.php?action=post& [L]

答案 1 :(得分:0)

在apache配置文件中禁用MultiViews。 在您的.htaccess中添加“Options -MultiViews”也可能有用。