目前,.htaccess文件将使用静态链接屏蔽动态链接,例如 www.example.com/news/news.php?article=foo-bar 将显示为 www.example.com/news/foo-bar / 。
但是,如果我想打开 www.example.com/news / 而不是 www.example.com/news/index.php ,它仍会重定向 www.example.com/news/news.php 例如最后添加?article = index 。
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^news/(.*)$ /news/news.php?article=$1 [L,QSA,NC]
有关如何解决此问题的任何建议吗?
答案 0 :(得分:1)
如果我正确理解你的问题,
您的REGEX应为^news/(.+)$
而不是^news/(.*)$
。
+
表示一个或多个
*
表示零或更多