【发布时间】:2018-07-01 18:46:49
【问题描述】:
我正在尝试将具有特定查询字符串的所有页面重定向到另一个页面。 很多页面都有这个查询字符串,但是 URI 是不同的。 我想捕获任何 URI,如果它有这个查询字符串来重定向它,但我没有做任何工作。
所以要明确一点:
http://example.com/?redirectme=1
将重定向到
http://example.com/newpage
同时:
http://example.com/randompage/rtandomsirectory?redirectme=1
还会重定向到
http://example.com/newpage
我确信必须有 2-3 行可以放入 htaccess 中才能执行此操作,但它不起作用。 如果这应该有所作为,这是一个 wordpress 网站。
这是我尝试过的:
RewriteCond %{REQUEST_URI} ^/(.+)
RewriteCond %{QUERY_STRING} ^redirectme=1$
RewriteRule ^/?$ http://example.com/? [R=301,L]
和
RewriteCond %{REQUEST_URI} ^/(.+)
RewriteCond %{QUERY_STRING} ^redirectme=1$
RewriteRule (.*) http://example.com/? [R=301,L]
不同的变体:
RewriteCond %{REQUEST_URI} (.+)
RewriteCond %{QUERY_STRING} ^redirectme=1$
RewriteRule (.*) http://example.com/? [R=301,L]
对于第一行:
RewriteCond %{REQUEST_URI} (.*)
等等……
这里有这方面的专家吗?
谢谢
【问题讨论】:
标签: wordpress apache .htaccess