Apache localhost重定向到一个本地网站

Apache localhost重定向到一个本地网站,apache,virtualhost,Apache,Virtualhost,我添加到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 "log

我添加到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>

服务器管理员webmaster@dummy-host2.example.com
DocumentRoot“C:/xampp/htdocs/mywebiste”
服务器名我的网站
ErrorLog“logs/error.log”
CustomLog“logs/access.log”通用
选项索引跟随符号链接多视图
选项-索引
不允许超限
命令允许,拒绝
通融
#重定向匹配^/$/index.php
选项+FollowSymLinks
IndexIgnore*/*
重新启动发动机
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则。index.php
现在,当我想向hosts文件和httpd-vhosts.conf添加新网站时,它会显示“mywebsite”,我无法访问该网站,即使我删除httpd-vhosts.conf中的虚拟主机并从hosts文件中删除我的条目,它仍然会显示“mywebsite”。我不知道该怎么做才能解决这个问题?

我想你需要

NameVirtualHost *:80
在任何
行之前


请参见

无论如何,您必须重新启动apache才能应用新设置:)抱歉。顺便说一句,NamevirtualHost根本不起作用。

但为什么我删除所有costum设置并在搜索栏中写下“localhost/mynewwebsite”,它会重定向到“localhost/mywebiste”?我甚至不能只写“localhost”,它只是将我重定向到“localhost/website”。@Townsheriff你试过
http://mynewwebsite
?这就是虚拟主机(而不是虚拟目录,比如
http://localhost/myvirtualdirectory