繁体   English   中英

301忽略动态网址

[英]301 ignoring dynamic url

好的,关于stackoverflow的第一篇文章,我去了。

我正在努力为旧网站的迁移编写301重定向。 该网站使用动态网址,但这些网址似乎无效。

旧网站: http : //oldsite.com/index.php?actie=contact

新网站: http//newsite.com/contact

Options +FollowSymlinks
RewriteEngine on
Redirect 301 /index.php?actie=contact http://newsite.com/contact

Redirec指令无法匹配查询字符串。

在root .htaccess中使用如下规则:

Options +FollowSymlinks
RewriteEngine on

RewriteCond %{QUERY_STRING} ^actie=contact$ [NC]
RewriteRule ^index\.php$ http://newsite.com/contact? [L,NC,R=301]

您无法与Redirect中的查询字符串匹配,必须使用mod_rewrite和%{QUERY_STRING}变量。 (还要注意, Redirect是mod_alias指令,与重写引擎无关)

选项+关注符号链接

RewriteCond %{QUERY_STRING} ^actie=contact(^|&)
RewriteRule ^index\.php http://newsite.com/contact? [L,R=301]

如果要使匹配actie=之后的任何内容成为通用规则,则:

RewriteCond %{QUERY_STRING} ^actie=([^&]+)
RewriteRule ^index\.php http://newsite.com/%1? [L,R=301]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM