[英]How do you allow index.php in .htaccess rewrite rule
At present, the .htaccess file will mask dynamic links with static links eg www.example.com/news/news.php?article=foo-bar will read as www.example.com/news/foo-bar/ . 目前,.htaccess文件将用静态链接掩盖动态链接,例如www.example.com/news/news.php?article=foo-bar将读取为www.example.com/news/foo-bar/ 。
However, if I wanted to open www.example.com/news/ instead of www.example.com/news/index.php , it still redirects it to www.example.com/news/news.php eg adding ?article=index on the end. 但是,如果我想打开www.example.com/news/而不是www.example.com/news/index.php ,它仍会将其重定向到www.example.com/news/news.php,例如添加?article =索引结束。
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^news/(.*)$ /news/news.php?article=$1 [L,QSA,NC]
Any suggestions on how to fix this? 对于如何解决这个问题,有任何的建议吗?
If I correctly understand your problem, 如果我正确理解您的问题,
your REGEX should be ^news/(.+)$
instead of ^news/(.*)$
. 您的REGEX应该是
^news/(.+)$
而不是^news/(.*)$
。
+
means one or more +
表示一个或多个
*
means zero or more *
表示零或更多
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.