【问题标题】:localhost redirects to one of local websiteslocalhost 重定向到本地网站之一
【发布时间】:2014-06-27 13:04:40
【问题描述】:

我添加到 C:/windows/system32/drivers/etc/hosts:

127.0.0.1 mywebiste

并在 httpd-vhosts.conf 中添加:

<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host2.example.com
    DocumentRoot "C:/xampp/htdocs/mywebiste"
    ServerName mywebsite
    ErrorLog "logs/error.log"
    CustomLog "logs/access.log" common

    <Directory "C:/xampp/htdocs/mywebiste">
        Options Indexes FollowSymLinks Multiviews
        Options -Indexes
        AllowOverride None
        Order allow,deny
        allow from all
        #RedirectMatch ^/$ / index.php

        Options +FollowSymLinks
        IndexIgnore */*
        RewriteEngine on
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule . index.php
    </Directory>
</VirtualHost>

现在,当我想将新网站添加到主机文件和 httpd-vhosts.conf 时,它会呈现“mywebsite”并且我无法访问该网站,即使我删除了 httpd-vhosts.conf 中的虚拟主机并从中删除了我的条目主机文件它仍然呈现“我的网站”。我不知道该怎么做才能解决这个问题?

【问题讨论】:

    标签: apache virtualhost


    【解决方案1】:

    我相信你需要

    NameVirtualHost *:80
    

    在任何&lt;VirtualHost...&gt; 行之前

    here

    【讨论】:

    • 但是为什么如果我删除所有的服装设置并在搜索栏中写入'localhost/mynewwebsite',它会重定向到'localhost/mywebiste'?我什至不能只写 'localhost' 它只是将我重定向到 'localhost/website'。
    • @Townsheriff 你试过http://mynewwebsite吗?这就是虚拟主机的意义(不是虚拟目录,比如http://localhost/myvirtualdirectory
    【解决方案2】:

    没关系,您必须重新启动 apache 才能应用新设置 :) 抱歉。顺便说一句,它根本无法使用 NamevirtualHost。

    【讨论】:

      猜你喜欢
      • 2012-11-12
      • 2020-05-13
      • 2018-01-06
      • 2015-12-14
      • 2020-10-04
      • 2019-11-13
      • 2021-01-24
      • 2019-03-19
      • 1970-01-01
      相关资源
      最近更新 更多