简体   繁体   English

域.301 .htaccess重定向

[英]Domain .301 .htaccess redirect

I have a domain on Namecheap that I set up to redirect to a url on a different site. 我在Namecheap上有一个域,将其设置为重定向到其他站点上的URL。 The problem is now it redirects everything, including paths that do not exist on the new site. 现在的问题是它重定向所有内容,包括新站点上不存在的路径。

So old url: 这么旧的网址:

domain.tld/bla/bla 

becomes 变成

newdomain.tld/theredirectedurl/bla/bla 

which throws a 404 error. 这会引发404错误。

My question is basically how to .301 all the incoming links from the old site to the new url: 我的问题基本上是如何.301从旧站点到新URL的所有传入链接:

newdomain.tld/theredirectedurl/

I tried setting up a refferer redirect but I think because the site goes thru Sucuri firewall that won't work. 我尝试设置中继器重定向,但我认为是因为该站点通过了Sucuri防火墙而无法正常工作。

RewriteEngine On 
RewriteCond %{HTTP_REFERER} ^http://olddomain.tld/[OR] 
RewriteCond %{HTTP_REFERER} ^http://www.olddomain.tld/ 
RewriteRule .* http://www.newdomain.tld/products/lines/product/ [R=301,L]

Any help would be appreciated. 任何帮助,将不胜感激。

Thanks 谢谢

Close. 关。 Use HTTP_HOST so it redirects immediately, referer [sic] wouldn't have any affect on first page view, only resources and subsequent clicks. 使用HTTP_HOST以便立即重定向,引用者[sic]不会对首页浏览产生任何影响,只会对资源和后续点击产生任何影响。

RewriteEngine On
RewriteCond %{HTTP_HOST} =olddomain.tld [OR]
RewriteCond %{HTTP_HOST} =www.olddomain.tld
RewriteRule ^ http://www.newdomain.tld/products/lines/product/ [R=301,L]

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

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