繁体   English   中英

正则表达式将所有以?layout = mobi或?layout = full结尾的网址重定向到首页

[英]Regex to redirect any url ending in ?layout=mobi or ?layout=full to homepage

将我的网站更改为wordpress。 过去具有移动和完整站点选项,其中?layout = mobi或?layout = full会调用这些文件。

现在在WMT中获得了很多404,例如example.com/page1.html?layout=mobi

我正在寻找正则表达式,以将所有以?layout = full或?layout = mobi结尾的404重定向到网站的首页,以使这些404不会阻塞我的WMT。

谢谢

尝试这种方式,在应用重定向到首页的RewriteRule之前先检查QUERY_STRING RewriteCond

RewriteEngine On
# Check if the query string contains layout=mobi OR layout=full
RewriteCond %{QUERY_STRING} ^(layout=mobi|layout=full)$
RewriteRule ^example.com/page1.html$ http://www.example.com/ [R=301,L]

暂无
暂无

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

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