You need to change the DocumentRoot setting in your httpd.conf file of Apache.
Chances are it will be under something like /etc/apache2/conf/httpd.conf
Use your favourite editor (I recommend Vim) and look for the DocumentRoot and change it
to /magento2.
Also look a little further down for a setting that looks like this:
<Directory "/var/www">
You will also want to change what is in the quotes to your new directory.
This gives Apache access to read from that directory when a user makes a request that call on it.
Now restart your apache service (httpd -k restart) and you should be good to go.
Edit: Apache2 site config files are now typically kept in /etc/apache2/sites-available/ (Debian, Ubuntu, etc.).
Sorry it was my mistake because pointed to a public dns ( http://www.example.com ).
But if you could give some hints on apache vhost configuration because every URI point to / when the correct is /Mengento/
I have updated my answer please check above answer !!
This is my configuration that doesn't work for URI point to / but only for /Magento
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog /var/www/logs/error.log
CustomLog /var/www/logs/access.log combined
<Directory /var/www/html/Magento>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Try below configuration :
<VirtualHost *:80> ServerName example.com ServerAlias www.example.com ServerAdmin webmaster@localhost DocumentRoot /var/www/html/Magento ErrorLog /var/www/logs/error.log CustomLog /var/www/logs/access.log combined <Directory /var/www/html/Magento> Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted </Directory> </VirtualHost>
Note : After doing this changes please restart your apache server
now I see the pages correctly but the link of admin : http://localhost/Magento/admin_1nfkvs/
is not found!
yes it is there in the root of magento