我如何mod_rewrite指向我的原始服务器的域名?

时间:2017-09-27 08:45:39

标签: php apache .htaccess mod-rewrite apache2

如何重写指向我的Origin Server的所有域 - 到我的域名?我想阻止其他域名托管我的内容!

1 个答案:

答案 0 :(得分:1)

大家好,这对任何与其他域有问题的人都有帮助,这些域指向Origin 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”并转发到重写所以https://或“yourdomain.com”的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”能够访问我的原始数据!

相关问题