.htaccess 将域重定向到404通用页
我有我的网站(a.com)。另一个人正在将您的域(b.com)指向我的服务器。这是错误的 是否可以将来自b.com的所有流量重定向到通用404页面?我认为这是可能的,有一个文件访问 谢谢你 编辑 我能做到吗.htaccess 将域重定向到404通用页,.htaccess,redirect,dns,web-hosting,.htaccess,Redirect,Dns,Web Hosting,我有我的网站(a.com)。另一个人正在将您的域(b.com)指向我的服务器。这是错误的 是否可以将来自b.com的所有流量重定向到通用404页面?我认为这是可能的,有一个文件访问 谢谢你 编辑 我能做到吗 RewriteEngine On RewriteRule ^(.*)$ http://www.b.com/$1 [R=404,L] 或 RewriteCond %{HTTP_HOST} ^www.b.com [nocase] RedirectMatch 404 ^(.*) 你可以这样做:
RewriteEngine On
RewriteRule ^(.*)$ http://www.b.com/$1 [R=404,L]
或
RewriteCond %{HTTP_HOST} ^www.b.com [nocase]
RedirectMatch 404 ^(.*)
你可以这样做:
order allow,deny
deny from b.com
allow from all
更新
RewriteEngine on
RewriteCond %{HTTP_REFERER} ^domainb\.com$ [NC]
RewriteRule .* - [R=404]
您还可以尝试一般禁止的错误,如:
order allow,deny
deny from b.com
allow from all
通过
httpd.conf
启用mod_rewrite和.htaccess,然后将此代码放入文档根目录下的.htaccess
:
Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_REFERER} b\.com [NC]
RewriteRule ^ /404.html [R=404,L]
这将检查流量是否来自b.com
,如果是,则将所有请求重定向到通用404.html
页面。我是如何将此代码放入htaccess文件的:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/index.html$
RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png|css|js)$
RewriteRule .* /index.html [L,R=302]
</IfModule>
重新启动发动机
重写cond%{REQUEST_URI}^/index.html$
重写条件%{REQUEST\u URI}!\。(gif | jpe?g | png | css | js)$
重写规则。*/index.html[L,R=302]
将请求发送到index.html文件。然后使用html中的刷新功能将文件重定向到所需的域:
index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<META http-equiv="refresh" content="0;URL=https://www.mydomain.co.uk/">
</head>
<body>
</body>
</html>
index.html
谢谢您的回答,我不想要像404.html或something.html这样的特定页面。我正在寻找一些更通用的服务器或找不到(没有html)。谢谢你!