Apache工作正常,除了127.0.0.1

时间:2017-07-14 16:45:04

标签: apache

一切正常,直到我发现了一个bug, 我的服务器无法在127.0.0.1上访问自己的服务。 我不确定是否相关但是当我在Internet Explorer中键入127.0.0.1时,它等待,然后说www.127.0.0.1无法访问。我确实添加了www。'最近被迫,但现在我将此脚本更改为' xxx。'而不是' www。'它仍然将我重定向到www.127.0.0.1,我网站的其余部分被重定向到' xxx。'

这是httpd.conf:

# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition.  These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#

#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
ServerAdmin admin@your-domain.com

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.net
ServerName 127.0.0.1

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
#DocumentRoot "c:/htdocs"
DocumentRoot "c:/htdocs"

#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features.  
#
<Directory />
    Options FollowSymLinks
    AllowOverride none
    Order deny,allow
    Deny from all
</Directory>

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "c:/htdocs">
    #
    # 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>

这是httpd-vhost.conf:

<VirtualHost 127.0.0.1:80>
    DocumentRoot c:/htdocs
    ServerName 127.0.0.1
    ServerAlias www.127.0.0.1 localhost www.localhost
    ErrorLog logs/example-intern-error.txt
    CustomLog logs/example-intern-access.txt common
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot c:/htdocs
    ServerName sa-arp.net
    ServerAlias www.example.net www.example.com example.com 
    ErrorLog logs/example-error.txt
    CustomLog logs/example-access.txt common

    RewriteEngine On
        RewriteCond %{HTTP_HOST} !^xxx\. [NC]
        RewriteRule ^(.*)$ http://xxx.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
</VirtualHost>

我尝试了所有可能的组合,似乎没有任何效果。

请帮助我,我没有资源和耐心!

谢谢,

RT-2

1 个答案:

答案 0 :(得分:0)

答案很简单,问题是WAS Internet Explorer, 我使用它是因为我在服务器上测试服务并且不想安装新程序。 好吧Firefox完成了工作并且工作,问题是测试方法。 RT-2

编辑:问题不在于Internet Explorer,问题是我创建了301重定向,这意味着浏览器记住了我告诉他的第一件事,然后我的所有测试对每个域都是徒劳的我已经测试了一次。 (是的,这令人沮丧)。我更新了这篇文章,以防有人有类似的代码和我的问题。