dsulli
dsulli

Reputation: 37

localhost redirects to vhost

OS: WinXP

Server: Xampp (Apache)

After using the zend cli tool to create an empty project, I added the suggested vhost section to my httpd-vhosts.conf and added the project name to the hosts file. The quickstart page for my project appears normal. However, now the path 'localhost' renders the project page, not the normal xmapp homepage.

This doesn't stop me for working, and I don't use the xampp homepage much, if at all. But I'm concerned that if I add more vhosts in the future there will be a conflict.

As per some other related posts, I uncommented NameVirtualHost line. But it didn't seem work. Then I tried each of the following but to no avail:

httpd-vhosts.conf

NameVirtualHost localhost

<VirtualHost *:80>
   DocumentRoot "C:/xampp/htdocs/cv/public"
   ServerName .local

   # This should be omitted in the production environment
   SetEnv APPLICATION_ENV development

   <Directory "C:/xampp/htdocs/cv/public">
       Options Indexes MultiViews FollowSymLinks
       AllowOverride All
       Order allow,deny
       Allow from all
   </Directory>

</VirtualHost>

hosts

127.0.0.1       localhost
127.0.0.1       cv

Upvotes: 1

Views: 1842

Answers (2)

filype
filype

Reputation: 8380

To access the site using the URL http://cv/ you have to change the ServerName directive. To keep things clean, use a pattern like http://*.local.net/

Also make sure that if you are using a proxy, you add that pattern to be an exception on your browser.

NameVirtualHost localhost

<VirtualHost *:80>
   DocumentRoot "C:/xampp/htdocs/cv/public"
   ServerName cv.local.net

   # This should be omitted in the production environment
   SetEnv APPLICATION_ENV development

   <Directory "C:/xampp/htdocs/cv/public">
       Options Indexes MultiViews FollowSymLinks
       AllowOverride All
       Order allow,deny
       Allow from all
   </Directory>

</VirtualHost>

Upvotes: 1

Jake
Jake

Reputation: 4374

From reading through, .local seems to be your problem.

# Setup "helloworld" Virtual Host
<VirtualHost *:80>
ServerName helloworld.tld
DocumentRoot "C:\projects\helloworld\public"

    <Directory "C:\projects\helloworld\public">
        Options Indexes FollowSymLinks Includes
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

Source: http://survivethedeepend.com/zendframeworkbook/en/1.0/creating.a.local.domain.using.apache.virtual.hosts#zfbook.creating.a.local.domain.using.apache.virtual.hosts.configuring.local.hosts.file

Upvotes: 1

Related Questions