正则表达式将任何以?layout = mobi或?layout = full结尾的网址重定向到主页

时间:2015-02-08 15:22:21

标签: regex wordpress url-redirection

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

现在在WMT中获得了大量的404,例如:http://www.page1.html?layout = mobi

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

由于

1 个答案:

答案 0 :(得分:0)

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

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]