configuring virtual host and localhost redirecting to the xampp folder

后端 未结 5 703
慢半拍i
慢半拍i 2020-12-13 19:35

I have problem with creating virtual host. I am using Windows 7 x64 Professional. In file C:\\Windows\\System32\\drivers\\etc\\hosts I have only this lines:

相关标签:
5条回答
  • 2020-12-13 19:41

    I had a similar issue and found that I had to go to my Apache24 main httpd.conf file and uncomment around line 501 "Include conf/extra/httpd-vhost.conf" I had never used that before and it was still #'ed out. Hope this helped anyone not finding other answers here. My Apache24 can now see my vhost file.

    0 讨论(0)
  • 2020-12-13 19:57

    try this

    [ file : C:\xampp\apache\conf\extra\httpd-vhosts.conf ]

    <VirtualHost basic.test:80>
        DocumentRoot "C:/xampp/htdocs/basic/public/"
        ServerName basic.test
    </VirtualHost>
    

    [ file : C:\Windows\System32\drivers\etc\hosts ] (open as admin)

    127.0.0.1  basic.test
    127.0.0.1  localhost
    
    0 讨论(0)
  • 2020-12-13 20:01

    You need to enable name-based virtual hosting.

    Near the top of the file in C:\xampp\apache\conf\extra\httpd-vhosts

    uncomment #NameVirtualHost *:80

    i.e. from:

    #
    # Use name-based virtual hosting.
    #
    #NameVirtualHost *:80
    

    To:

    #
    # Use name-based virtual hosting.
    #
    NameVirtualHost *:80
    

    (Note the last line now is uncommented).

    Worked like a charm for me. :)

    0 讨论(0)
  • 2020-12-13 20:02

    I had this same issue. Your first request is redirecting to the htdocs root directory. If you look at index.php in the htdocs directory, you can see very brief code that takes the incoming request and redirects it to the xampp directory.

    I fixed it by fiddling with the httpd-vhosts.conf file. In your case, try making the following edits:

    NameVirtualHost 127.0.0.1
    <VirtualHost 127.0.0.1> 
        DocumentRoot "C:\xampp\htdocs\
        ServerName localhost
    </VirtualHost>
    
    <VirtualHost www.myhost> 
        DocumentRoot "C:\Users\Me\Dropbox\Project\public"
        ServerName www.myhost
        ServerAlias www.myhost
        <Directory "C:\Users\Me\Dropbox\Project\public">
            Options Indexes FollowSymLinks Includes ExecCGI
            AllowOverride All
            Order allow,deny
            Allow from all
       </Directory>
    </VirtualHost>
    
    0 讨论(0)
  • 2020-12-13 20:05

    For me replacing this one <VirtualHost *:80> to this <VirtualHost 127.0.0.1:80> working fine.

    0 讨论(0)
提交回复
热议问题