将 www.example.com/some-path/example/ 重定向到 www.example.com/some-path/?ABC=123

Redirect www.example.com/some-path/example/ to www.example.com/some-path/?ABC=123

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

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

我试过的是:

RedirectMatch 301 /sg/(.*) /?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 ^(.*)/(.*)/?$ //?ls= [R=301,NE,L]