[英]Redirect wordpress home page by referrer http request
I need to redirect to a static *.html page my wordpress homepage when the http request come from instagram website.我需要重定向到 static *.html 页面我的 wordpress 主页当 Z80791B3AE7002CB8F8C24 请求来自 instagram 网站时。 I tried to add this code in a custom plugin, but it doesn't work:
我尝试将此代码添加到自定义插件中,但它不起作用:
add_action('template_redirect', 'redirect_ref');
function redirect_ref () {
$referer = wp_get_referer();
if (is_home() && strpos(parse_url(wp_get_referer())['host'],'l.instagram.com'))){
wp_redirect('/custom_page.html');
}
i think i understood your problem.我想我理解你的问题。
The best way is to solve it via a get parameter.最好的方法是通过获取参数来解决它。 You can add this to your
.htaccess
file您可以将此添加到您的
.htaccess
文件中
RewriteEngine on
RewriteCond %{QUERY_STRING} inst
RewriteRule ^$ /example.html? [L,R=301]
and link your webpage with this link:并使用此链接链接您的网页:
www.yourpage.de?inst
and it will redirect to www.yourpage.de/example.html
它将重定向到
www.yourpage.de/example.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.