簡體   English   中英

由引用者 http 請求重定向 wordpress 主頁

[英]Redirect wordpress home page by referrer http request

我需要重定向到 static *.html 頁面我的 wordpress 主頁當 Z80791B3AE7002CB8F8C24 請求來自 instagram 網站時。 我嘗試將此代碼添加到自定義插件中,但它不起作用:

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');
}

我想我理解你的問題。

最好的方法是通過獲取參數來解決它。 您可以將此添加到您的.htaccess文件中

RewriteEngine on
RewriteCond %{QUERY_STRING} inst
RewriteRule ^$ /example.html? [L,R=301]

並使用此鏈接鏈接您的網頁:

www.yourpage.de?inst

它將重定向到www.yourpage.de/example.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM