All Apache requests pointing to the same directory

Asked

Viewed 556 times

0

I set up a Vhost for my project as follows:

1 - I added a line to the file /etc/hosts containing local address, url and alias

127.0.0.1 meuprojeto.com meuprojeto

2 - I added the file meuprojeto.conf in /etc/apache2/sites-enabled/meuprojeto.conf containing the following information:

<VirtualHost www.meuprojeto.com>
    ServerAdmin webmaster@localhost
    ServerName wwww.meuprojeto.com
    ServerAlias meuprojeto
    DocumentRoot "/var/www/html/meuprojeto"
</VirtualHost>

There is a copy of this file on /etc/apache2/sites-available

I can access my project from the normally declared url.

The problem is that all requests now point to the root of the project. In case you enter the address http://localhost the request falls in the /var/www/html/meuprojeto.

I’ve checked the apache root directory on /etc/apache2/apache.conf and it points to:

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

Thank you for your attention.

  • The Host Apparently wrong, try to put it like this: 127.0.0.1 meuprojeto.com and 127.0.0.1 www.meuprojeto.com bottom. Not Counting that in config there, is with 4 wwww.

  • @Raphaelcaldas, I think it was a typo, hehe. I made the suggested changes but had no change. Ai tried to use a2ensite meuprojeto, somehow the browser started to display the default index that exists in localhost ("it, Works!"). But when I try to access another localhost/project2 project, there is still redirection to /var/www/html/meuprojeto

1 answer

0


Hi buddy I went to take a look at my own vhost here and caught it to show you, below already adapted:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName wwww.meuprojeto.com
    ServerAlias meuprojeto.com
    DocumentRoot C:/var/www/html/meuprojeto (não sei como é o seu caminho completo)
</VirtualHost>

Good Luck, just adapt the Documentroot there.

  • We’re almost there! I changed to <VirtualHost www.meuprojeto.com:80> the test title and it worked. However there is still something wrong. Obeserve that when I enter localhost it opens the default apache index, if I report 127.0.0.1 it falls at the root of the project. But I still can’t access other local addresses...

  • This error is no longer in vhost, it is in Hosts now, in that part I do not know how to help you, unfortunately. I use xampp that already helps me a lot in this vhost.

  • In fact @Raphaelcaldas, the problem is that localhost and meuprojeto, in the hosts file, Stavamo with the same ip 127.0.0.1. I changed localhost to 127.0.0.2 and everything went fine. Thanks for your attention! Hug.

Browser other questions tagged

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