简体   繁体   English

通过htaccess从特定的URL重定向用户

[英]Redirect users from specific url via htaccess

Is it possible to redirect a user who is coming from a specific url to another url via htaccess or script? 是否可以通过htaccess或脚本将来自特定URL的用户重定向到另一个URL? (htaccess prefered) (首选htaccess)

eg 例如

user comes from www.domain-a.com/sample-site/ to www.domain-b.net/sample-site2/ and should be redirect to www.domain-c.org/sample3/ All other user shouldn't be redirected only the users from www.domain-a.com/sample-site/ 用户来自www.domain-a.com/sample-site/到www.domain-b.net/sample-site2/,应该重定向到www.domain-c.org/sample3/其他所有用户都不应仅将用户从www.domain-a.com/sample-site/重定向

Domain-a and domain-b are wordpress sites. 域a和域b是wordpress网站。

Thanks for the help 谢谢您的帮助

Assuming you have control over domain-b.net: 假设您可以控制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]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM