[英]RewriteRule on apache2
我对Rewrite
规则有Rewrite
。 我想将domain.xx/example
重定向到domain.xx/index.php?content=example
这实际上可以工作,但是我在同一文件夹( domain.xx/example.php
)中也有一个名为example.php的文件。 每当我打开domain.xx/example
,服务器就会打开example.php
而不是将我重定向到index.php?content=example
。
当我删除example.php
文件时, mod-rewrite
处于打开状态,并且工作正常。
RewriteEngine On
RewriteBase /
RewriteRule ^example$ index.php?content=example [NC,L]
重写规则是正则表达式,因此您只需要删除结尾字符以匹配example和example.php
RewriteRule ^example index.php?content=example [NC,L]
那是因为有MultiViews
选项。
将此行添加到.htaccess的顶部:
Options -MultiViews
将此添加到您的htaccess文件中:
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
因此example.php将直接提供,然后添加您的规则。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.