简体   繁体   English

将所有流量从外部域重定向到本地域主页?

[英]Redirect all traffic to from external domain to local domain homepage?

There is an external website which is redirecting all its traffic to webpages on our site. 有一个外部网站将其所有流量重定向到我们网站上的网页。 We can't control this redirection and the content URLs are mirrored in the following way. 我们无法控制此重定向,并且内容URL通过以下方式进行镜像。

When users go to: 当用户转到:

www.externaldomain.com/1234 

they get redirected to: 他们被重定向到:

www.ourdomain.com/1234 

which can sometimes be a non-existant page and thus a 404 error results. 有时可能是不存在的页面,从而导致404错误。 How can I re-direct all traffic from externaldomain.com to ourdomain.com homepage to make sure we don't lose potential users? 如何将所有流量从externaldomain.com ourdomain.comourdomain.com主页,以确保我们不会失去潜在用户?

I know HTTP_REFERER comes into play, but I'm having trouble setting it up getting it to function properly. 我知道HTTP_REFERER可以发挥作用,但是我无法对其进行设置使其无法正常运行。

See this answer 看到这个答案

You must use modrewrite of apache: 您必须使用modrewrite的apache:

RewriteEngine On RewriteEngine开

RewriteCond %{HTTP_REFERER} !^mydomain.co.uk$ [N] RewriteCond%{HTTP_REFERER}!^ mydomain.co.uk $ [N]

The most important question to ask here is whether you wish to redirect all traffic to your homepage or specific pages that you've mentioned 'sometimes' don't exist (404) - both of which which are answered here. 这里要问的最重要的问题是,您是要将所有访问量重定向到您的首页还是提到的“有时”不存在的特定页面(404)-两者均在此处得到了回答。

Redirecting all referred traffic to a homepage from a specific external domain 将所有引荐流量从特定外部域重定向到首页

Where you need to redirect all traffic from a specific domain (referrer), you can do the following: 在需要重定向来自特定域(引荐来源网址)的所有流量的地方,可以执行以下操作:

 RewriteEngine On 
 RewriteCond %{HTTP_REFERER} ^http://externaldomain\.com/ [NC]
 RewriteRule ^(.*) /index.php [R=301,L] 


Redirecting only 404 error traffic to a homepage from a specific domain 仅将404错误流量从特定域重定向到首页

If you want to redirect on this basis then use: 如果要在此基础上重定向,请使用:

 RewriteEngine On 
 RewriteCond %{HTTP_REFERER} ^http://externaldomain\.com/ [NC]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^(.*) /index.php [R=301,L] 


With regard to the apache flags noted above: 关于上面提到的apache标志:

 [NC]    = No case (or case insensitive)
 [L]     = If the rule matches, no further rules will be processed.
 [R=301] = Apply a 301 redirect*

You can find more verbose/detailed info on Apache flags here . 您可以在此处找到有关Apache标志的更多详细信息。


*Search engine optimisation for these rules *针对这些规则的搜索引擎优化

Why a 301 redirect? 为什么301重定向? - A 301 redirect is a permanent redirect which passes more than 90+% of link juice (or potential ranking power ) to the redirected page. -301重定向是一种永久重定向,它将超过90%以上的链接汁(或潜在的排名能力 )传递到重定向页面。 301 refers to the HTTP status code for this type of redirect. 301指的是这种重定向类型的HTTP状态代码。 In most instances, the 301 redirect is the best method for implementing redirects on a website in terms of SEO. 在大多数情况下,就SEO而言,301重定向是在网站上实施重定向的最佳方法。 In terms of benefit, there is a wealth of information here on how to capitalise on and deal with different types of redirect. 在效益方面,有丰富的信息在这里就如何利用和处理不同类型的重定向。

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

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