无法重定向到新链接

Posted

技术标签:

【中文标题】无法重定向到新链接【英文标题】:Can not redirect to new link 【发布时间】:2019-07-12 13:35:00 【问题描述】:

我正在设置将我的链接重定向到新链接,但我尝试在 vhost 中设置很多次,设置效果不佳。请帮我。 我正在使用 apache 2.4

旧链接:/ac/bc?pagename=Test/TestClassfication&id=006&level=001

新链接:/ac/test/006.html

我的设置: RewriteRule ^/ac/bc?pagename=Test/TestClassfication&id=006&level=001$ /ac/test/006.html [R=301,L]

我也用这个设置检查了一些在线工具,但没有用。

RewriteCond %QUERY_STRING (^|&)pagename\=Test/TestClassfication($|&)

RewriteCond %QUERY_STRING (^|&)id\=006($|&)

RewriteCond %QUERY_STRING (^|&)level\=001($|&)

重写规则 ^ac/bc$ /ac/test/006.html? [L,R=301]

【问题讨论】:

【参考方案1】:

我找到了解决办法,谢谢大家。

RewriteCond %REQUEST_URI ^/ac/bc

RewriteCond %QUERY_STRING ^pagename=Test/TestClassfication&id=006&level=001$

重写规则 ^(.*) /ac/test/006.html? [R=301,L]

【讨论】:

以上是关于无法重定向到新链接的主要内容,如果未能解决你的问题,请参考以下文章

htaccess 域重定向到新域

301 使用 .htaccess 重定向到新域并编辑一些特定链接

WordPress优化:更改网站的固定链接并将旧链接重定向到新链接

使用 .htaccess 从旧页面重定向到新页面

重定向到新的外部 url 时如何保留 localStorage [重复]

Nginx 配置旧域名重定向到新域名