【问题标题】:IP canonicalization - When IP adress is typed I want it to direct to the domain nameIP 规范化 - 当输入 IP 地址时,我希望它指向域名
【发布时间】:2020-10-10 16:10:21
【问题描述】:

我有 Ubuntu 20.04.1 Apache 2.4.41 webserver(digitalOcean) 具有 SSH 根访问权限和域名形式 GoDaddy .

运行 Wordpress 5.4.2 版,一切正常,但我不知道如何进行 IP 规范化。我已经尝试了几种使用 .htaccess 的方法,但对我来说没有任何效果。当输入 IP 地址时,我希望它指向域名。

【问题讨论】:

    标签: wordpress apache server webserver apache2


    【解决方案1】:

    您可以在 httd.conf 文件中使用以下重写规则。

    <VirtualHost XX.XX.XX.XX>
    
    DocumentRoot "/var/www/html"
    ServerName test.com
    
     # Other directives here
     RewriteEngine On
     RewriteCond %{HTTP_HOST} !^test.com$
     RewriteRule ^(.*)$ http://test.com$1 [R=301,L] 
    
    </VirtualHost>
    

    【讨论】:

    • 我没有 httd.conf 文件只有 apche2.conf 我应该把这些行放在 apacahe2.conf 哪里?
    • 您是否在 apache2.conf 文件中使用任何 VirtualHost?如果是,则在 VirtualHost 内部使用,否则在 VirtualHost 外部使用。
    猜你喜欢
    • 1970-01-01
    • 2017-12-27
    • 2013-11-03
    • 1970-01-01
    • 2011-04-07
    • 1970-01-01
    • 2015-10-03
    • 1970-01-01
    • 2019-05-31
    相关资源
    最近更新 更多