带有问号的URL重定向

时间:2019-01-31 18:11:50

标签: apache .htaccess url-rewriting url-redirection

嗨,我需要有关RewriteRule的帮助以转发以下网址:

https://example.com/ipsum-lorem-amit/?lang=en

https://example.com/en/a-newpage-here

我尝试了以下代码,但是它不起作用

RewriteCond %{REQUEST_URI} ^/tipsum-lorem-amit/?lang=en [NC]
RewriteCond %{QUERY_STRING} lang=en [NC]
RewriteRule ^(.*) %{REQUEST_URI}/en/a-newpage-here [R,L]

感谢您的帮助

1 个答案:

答案 0 :(得分:1)

您可以将此规则用作您的“ 最高规则”:

RewriteEngine On

RewriteCond %{QUERY_STRING} ^lang=([a-z]+)$ [NC]
RewriteRule ^tipsum-lorem-amit/?$ /%1/a-newpage-here? [R=301,NC,L]