.htaccess rewritecond,多个匹配项
如何重写此URL:.htaccess rewritecond,多个匹配项,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,如何重写此URL: http://example.com/no/news/archive/ 到 谢谢 # inside .htaccess for the document root of example.com RewriteBase / # good habit; not needed for this absolute rewrite though # rewrite exact URL RewriteRule ^index.php\?lang=en&uri=/news/a
http://example.com/no/news/archive/
到
谢谢
# inside .htaccess for the document root of example.com
RewriteBase / # good habit; not needed for this absolute rewrite though
# rewrite exact URL
RewriteRule ^index.php\?lang=en&uri=/news/archive/$ /no/news/archive/
您可能希望匹配更加灵活。如果
lang
不存在或不存在en
,该怎么办?或者出现在uri=/news/archive
之后?此外,客户是否可以请求/news/archive/
下的子目录,并且所有这些请求是否都应该转到/no/news/archive/
?因为您没有提供太多信息,这里是应该解决的问题:
RewriteRule ^/no/news/archive/$ /index.php?lang=en&uri=/news/archive/
但这不是很灵活
如果您想要更深入的答案,请提供更多信息。您可以使用以下代码:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^no(/news/archive/?)$ index.php?lang=en&uri=$1 [L,QSA,NC]
是的,我希望它是灵活的。
lang
应该在en
和no
之间切换,uri
可以是任何内容。
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteRule ^no(/news/archive/?)$ index.php?lang=en&uri=$1 [L,QSA,NC]