Apache directing two URLs to the same folder

2

I have 2 sf2 projects in different folders. When they access the URLs localhost/projeto01 and localhost/projeto02 m go to same location (project01 even when access / project02).

I created a vhost after that to see if it solved but it did not solve:

The problem was before the vhosts were created. No error appears in sf2 or apache application logs.

Apache 2.4.6 Release
SF Symfony 2.4 Release
OS Version: XUbuntu 13.10

Note: The URLs accessed are different and the directories are different. Both projects print different messages in the view, but they are the same. Even accessing normally through the localhost / project happens the problem.

    
asked by anonymous 27.02.2014 / 03:41

2 answers

2

I understand that you are creating virtualhosts but trying to access as localhost; if this is not going to work! For the virtualhost to work you need to access the URL by host name otherwise how apache will know where to get the files?

If you want the url http://localhost/projeto1 to access a directory other than http://localhost/projeto2 , the simplest way would not be using "aliases"?

Something like:

Alias /projeto1 /var/www/sort/cliente/web
<directory>
(...)
</directory>

Alias /projeto2 /var/www/sort/dashboard/web
<directory>
(...)
</directory>

Or you can keep the configuration via vhosts and put the names in / etc / hosts, something like:

127.0.0.1 localhost <--- ESSE JÁ DEVE EXISTIR
127.0.0.1 projeto1
127.0.0.1 projeto2

Access in this case would be http://projeto1 and http://projeto2 ; Note that the name of VirtualHost is now part of the URL that, thanks to editing on hosts resolves to the same ip.

    
09.04.2014 / 03:07
0

In Apache 2.4, the NameVirtualHost directive has gone deprecated. It is recommended to configure "IP-based Virtual Host": link

  • Remove NameVirtualHost

  • In the "listening" policy, specify the ports you want to use: Example for port 80: Listen 127.0.0.1:80

  • In the VirtualHost tag, change the asterisk to the IP number. Example < VirtualHost 127.0.0.1:80 >

  • Note: IP 127.0.0.1 is a local IP number. The examples above are illustrative.

        
    04.03.2014 / 06:28