【发布时间】:2017-09-27 16:45:38
【问题描述】:
如何将所有指向我的源服务器的域重写为我的域名?我想阻止其他域托管我的内容!
【问题讨论】:
标签: php apache .htaccess mod-rewrite apache2
如何将所有指向我的源服务器的域重写为我的域名?我想阻止其他域托管我的内容!
【问题讨论】:
标签: php apache .htaccess mod-rewrite apache2
大家好,这对那些在指向原始 IP 的其他域有问题并且索引比他们更高的人有帮助,依此类推!你需要做的第一件事
确保在您的 httpd.conf 文件中启用了 mod_rewrite.so 模块
Include conf.modules.d/*.conf
LoadModule rewrite_module modules/mod_rewrite.so
您还必须确保允许 .htaccess 文件覆盖所有:
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
完成此操作后,您可以设置 301 永久重定向 - 所以在我的情况下,您需要做的就是设置“www”的转发器。 “yourdomain.com”并将其转发给“yourdomain.com”的 https:// 或 http:// 重写。您可以在您的 DNS 管理器的页面设置中执行此操作,或者将此代码复制到您的重写条件下的 .htaccess 文件中
Options FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS_HOST} !^https://yourdomain.com$
RewriteRule ^/?(.*) https://www.my-domain.com/$1 [QSA,R=301,L]
现在您可以看到我已经为 https:// 连接设置了重写 - 如果您想重写 http,只需删除 S 等第四个!
我的问题是,我现在完全不知道如何阻止我的“targetdomain.com”访问我的来源数据!
【讨论】: