重写IP地址以显示URL

时间:2014-03-04 03:21:42

标签: php .htaccess mod-rewrite

我的服务器stack.zachstarnes.com上有一个子域,它目前指向数字海洋液滴。当您在浏览器中键入上述地址时,它最终显示其重定向到的IP地址,我希望它显示stack.zachstarnes.com。

我在与index.php文件相同的目录中添加了一个.htaccess文件:

RewriteCond %{HTTP_HOST} ^107\.170\.67\.157
RewriteRule (.*) http://www.stack.zachstarnes.com/$1 [R=301,L]

但这不起作用,因为它仍显示IP地址。我还确保进入.conf文件并将AllowOverride None更改为AllowOverride FileInfo我做错了什么?任何帮助都会很棒!

这是错误日志

[Tue Mar 04 02:39:08 2014] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue Mar 04 02:39:08 2014] [notice] suEXEC mechanism enabled (wrapper: /usr/bin/suexec)
[Tue Mar 04 02:39:08 2014] [notice] Digest: generating secret for digest authentication ...
[Tue Mar 04 02:39:08 2014] [notice] Digest: done
[Tue Mar 04 02:39:08 2014] [notice] Apache/2.2.26 (Unix) mod_ssl/2.2.26 OpenSSL/1.0.1e DAV/2 configured -- resuming normal operations
[Tue Mar 04 02:40:27 2014] [error] [client 24.126.213.31] File does not exist: /srv/http/favicon.ico
[Tue Mar 04 02:50:58 2014] [notice] caught SIGWINCH, shutting down gracefully
[Tue Mar 04 02:50:59 2014] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue Mar 04 02:50:59 2014] [notice] suEXEC mechanism enabled (wrapper: /usr/bin/suexec)
[Tue Mar 04 02:50:59 2014] [notice] Digest: generating secret for digest authentication ...
[Tue Mar 04 02:50:59 2014] [notice] Digest: done
[Tue Mar 04 02:50:59 2014] [notice] Apache/2.2.26 (Unix) mod_ssl/2.2.26 OpenSSL/1.0.1e DAV/2 PHP/5.5.9 configured -- resuming normal operations

这是httpd.conf文件中的相关代码

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/srv/http">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # 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

    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all

</Directory>

0 个答案:

没有答案