我有以下规则:
RewriteRule ^news/([^/]*)$ /news.php?lang=$1 [L]
在这里,我可以使用http://domain.tld/news/de访问该网站,但我无法通过http://domain.tld/news/de/(最后反斜杠)与他们联系。
我该怎么做?
第二个问题是如何将这3条规则简化为一条,因为它处理所有相同的页面?
# News
RewriteRule ^news/page/([^/]*)/([^/]*)$ /news.php?page=$1&lang=$2 [L]
RewriteRule ^news/page/([^/]*)$ /news.php?page=$1 [L]
RewriteRule ^news/([^/]*)$ /news.php?lang=$1 [L]
提前致谢。
答案 0 :(得分:0)
使用可选的尾部斜杠,并可选择关闭MultiViews
:
Options -MultiViews
RewriteEngine On
RewriteRule ^news/page/([^/]+)/([^/]+)/?$ news.php?page=$1&lang=$2 [L,QSA,NC]
RewriteRule ^news/page/([^/]+)/?$ news.php?page=$1 [L,QSA,NC]
RewriteRule ^news/([^/]+)/?$ news.php?lang=$1 [L,QSA,NC]