Apache directing two Urls to the same folder

Asked

Viewed 793 times

2

I have 2 sf2 projects in different folders. When I access them through Urls localhost/projeto01 and localhost/projeto02m go to the same location (project01 even when access /project02).

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

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

Apache version 2.4.6
SF Symfony Version 2.4
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 by localhost/project happens the problem.

inserir a descrição da imagem aqui

  • 1

    I think the directive is missing NameVirtualHost *:80 in each of the vhosts.

  • Probably is the Namevirtualhost *:80 same, but that would not explain the situation of localhost/project02 open the same folder contents localhost/project01 This made me curious about cas, is there a . htaccess in the root of the application folder that opens? this could capture the requisition and cause this symptom

2 answers

2

From what I understand you are creating virtualhosts but trying to access as localhost; if so it will not work at all! For virtualhost to work you need to access the URL by host name otherwise how apache will know where to get the files?

If what you want is that url http://localhost/projeto1 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 by vhosts and put the names in the /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 which, thanks to editing in hosts solves for the same ip.

0

In Apache 2.4, the directive Namevirtualhost went into disuse (deprecated). "IP-based Virtual Host configuration recommended": http://httpd.apache.org/docs/2.4/en/vhosts/ip-based.html

  1. Remove Namevirtualhost

  2. In the "listening" directive, specify the ports you want to use: Example for door 80: Listen 127.0.0.1:80

  3. On the Virtualhost tag, exchange the asterisk for the IP number. Example < VirtualHost 127.0.0.1:80 >

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

  • This is troubling! Where did you see that the use of named vhosts has fallen into disuse? What about the case of Shared hosts where the same server responds to "N" hosts on the same IP? Just the idea of allocating separate addresses to each server I have gives me chills.

  • Knowing how to read and write is different from understanding what you read and write.. rsrs Read again and pay attention to what you will understand. Also make a small effort in searching. With two words on google you will find thousands of answers.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.