将www.example.com/some-path/example/重定向至www.example.com/som-p



我正在尝试重定向这样的路径:从www.example.com/some-path/sg/www.example.com/some-path/

但我需要某种方法来识别这个流量,理想情况下是这样一个参数:www.example.com/some-path/?ls=sg。这可能使用htaccess/mod_rewrite吗?

我尝试过的是:

RedirectMatch 301 /sg/(.*) /$1?ls=SG7

对于您显示的尝试,示例请尝试以下htaccess规则文件。请确保将它们放在htaccess规则文件的顶部。

在测试URL之前,请确保清除浏览器缓存。

RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
##To look for sg here.
RewriteCond %{THE_REQUEST} sg [NC]
RewriteRule ^(.*)/(.*)/?$ /$1/?ls=$2 [R=301,NE,L]

相关内容

最新更新