简体   繁体   English

什么是适当的.htaccess来阻止分配给我专用IP的另一个网站

[英]What is the proper .htaccess for blocking another website assigned to my dedicated IP

Here is my scenario: I have a website, that I own, and another website, which someone I don't know owns, is also assigned to that same IP address. 这是我的情况:我有一个我拥有的网站,另一个我不认识的人拥有的网站也分配给了该IP地址。 When I view their website it is basically displaying all of the content from my website. 当我查看他们的网站时,它基本上是在显示我网站上的所有内容。 This URL is #1 in certain keywords I'm using any my website is several pages deep in google. 我在任何网站上使用的某些关键字中此URL排名第一,在google上有几页。 I can also log into the administrator portion of the website through the other URL that I don't own, which worries me from a liability stand point. 我还可以通过我不拥有的其他URL登录网站的管理员部分,这从责任角度使我感到担忧。 I contacted my hosting provider and after about an hour and nothing to show for it here I am. 我联系了我的托管服务提供商,大约一个小时后,这里没什么可显示的。

What I want to do is block the other website in .htaccess OR completely redirect all pages from that URL to my URL... 我想做的是在.htaccess中屏蔽其他网站,或者将所有页面从该URL完全重定向到我的URL ...

What is the best redirect method or code in this instance? 在这种情况下,最好的重定向方法或代码是什么?

What I currently have still in my .htaccess allows the index page to be loaded on the remote website but all of the images and css loaded by that index page respond with a 403 forbidden. 我目前在.htaccess中仍然拥有的内容允许将索引页面加载到远程网站上,但是该索引页面加载的所有图像和CSS均禁止403响应。 Problem with that is it is still loading my index page's meta description, keywords, html, and styles which is messing with my search engine optimization attempts. 问题在于它仍在加载索引页面的元描述,关键字,html和样式,这与我的搜索引擎优化尝试相混淆。

I want the index page to not even load resulting in a forbidden error or a complete redirect including the base index page. 我希望索引页面甚至不加载,从而导致禁止的错误或包括基本索引页面的完整重定向。

I also want to redirect any traffic that doesn't include the www before my domain to the www version and not result in a redirection loop. 我还想将域之前不包含www的所有流量重定向到www版本,并且不会导致重定向循环。

Any help is greatly appreciated. 任何帮助是极大的赞赏。

RewriteCond %{HTTP_REFERER} otherdomain\.com [NC]
RewriteRule .* - [F]
RewriteCond %{HTTP_HOST} ^otherdomain\.com [NC]
RewriteCond %{HTTP_HOST} ^mydomain\.com [NC]
RewriteRule ^(.*)$ http://www\.mydomain\.com [R=301,L]

Use this code: 使用此代码:

# block other domain
RewriteCond %{HTTP_HOST} ^(www\.)?otherdomain\.com$ [NC]
RewriteRule ^ - [F]

# put www before host name
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

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

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