2015-09-27 73 views
0

是否可以通過htaccess或腳本將來自特定網址的用戶重定向到另一個網址? (htaccess首選)通過htaccess從特定網址重定向用戶

例如

用戶來自www.domain-a.com/sample-site/至www.domain-b.net/sample-site2/,並應重定向至www.domain-c.org/sample3/ 所有其他用戶不應該被重定向僅來自www.domain-a.com/sample-site/的用戶

域-a和域-b是wordpress站點。

感謝您的幫助

+0

域,和域-B是我的控制 – user384671

回答

-1

假設你有控制domain-b.net:

RewriteEngine on  
#If user clicks a link on a page sample-site of domain A 
#which you may or may not control 
    RewriteCond %{HTTP_REFERER} ^http://(www.)?domain-a\.com/sample-site/? [NC] 
#which aims at domain B, which you control, which runs this .htaccess file 
    RewriteCond %{HTTP_HOST} ^www.domain-b.net$ 
#requesting page sample-site2 
    RewriteCond %{REQUEST_URI} ^/?sample-site2/? 
#then rewrite to domain C page sample3 
    RewriteRule^http://www.domain-c.org/sample3/ [R,L] 
+0

爲A和B是屬於我的。我會嘗試並提供反饋。謝謝 – user384671

+0

好的,我插入在我的htaccess,但它不起作用。我不明白帶有{http_referer}的行。有什麼問題 – user384671

+0

RewriteEngine on RewriteCond%{HTTP_REFERER}^http://(www。)?domain-a \ .de/category/li-test /? [NC] RewriteCond%{HTTP_HOST}^www.domain-b.net $ RewriteCond%{REQUEST_URI}^/?category/re-test /? RewriteRule^http://www.domain-c.org/sample3/ [R,L] – user384671