Unable to get localhost to display WampServer index and dynamic URLs at the same time

I have Wamp installed, so I can run some simple dynamic sites that I created. I want to have three or four and learn how to do things locally and then upload the improved files to the site without having to rewrite sections due to different locations / paths, etc.

To show the WampServer index page, I go to http-vhosts.conf and add

<VirtualHost 127.0.0.1>
ServerName localhost
DocumentRoot "E:/wamp/www"
</VirtualHost>

I understand that I put the directory of my site with the name mysite.local in E: wamp / www, so the path will become E: wamp / www / mysite.local. Then I go to http-vhosts.conf and add

<VirtualHost *:80>
ServerName mysite.local
DocumentRoot "E:/wamp/www/mysite.local"
</VirtualHost>

at my host file

 127.0.0.1 localhost 127.0.0.1 mysite.local 

and my httfp.conf has

 # Virtual hosts Include conf/extra/httpd-vhosts.conf 

So, my problem with all this, I get that my WampServer index shows when I type localhost in the URL and mysite.local appears on this index page in the β€œYour Projects” section, which is good, but when I click on mysite .local link from WampServer, url changes to localhost / mysite.local, not mysite.local, and then when I click on the page link from localhost / mysite.local, I get localhost / mysite.local / linkedpage as url And 404 error.

mysite.local since the url also displays the WampServer index page

If I comment on localhost server_name from http-vhosts.conf and restart apache. I get what I need when I try mysite.local, when url-mysite works, and all dynamic links work. but the WampServer index is a 404 error.

All I want to do is log in to WampServer and visit various sites from the "Your Projects" list.

Please help numpty

+6
source share
3 answers

hosts and httpd.conf look OK.

Some things to try ...

  • <VirtualHost *:80> for both virtual hosts.

  • Make sure the DocumentRoot lines have a / terminal.

  • For the root virtual host, ServerName localhost:80 .

  • To browse through virtual hosts, always omit localhost/ from the URL. Your projects links include localhost/ and access to projects as paths from the root, rather than to independent sites, each with its own root (which provides you with virtual hosts).

  • (WAMP 2) When everything else is fixed ... to animate the page "Your virtual hosts" on the root page "index.php", follow these instructions . I just did it and do not regret it. Now I can click links to access my sites that serve as virtual hosts - yay! What I always wanted from the links "Your projects", but did not receive.

BTW, the directives <VirtualHost>...</VirtualHost> is what associates each host name with a specific path in the server file system, therefore in the subdirectories in "E: / wamp / www /" the suffix ".local" is not needed , After removing ".local" from the drives themselves, make the appropriate changes to the DocumentRoot entries, for example, DocumentRoot "E:/wamp/www/mysite/" . But don't forget to leave ".local" in the "ServerName" entry, for example. ServerName mysite.local to match the entries in your hosts file.

+4
source

The following is a reasonable definition of vhosts

 # # Use name-based virtual hosting. # NameVirtualHost *:80 ## must be first so the the wamp menu page loads <VirtualHost *:80> ServerAdmin webmaster@homemail.net DocumentRoot "D:/wamp/www" ServerName localhost ServerAlias localhost <Directory "D:/wamp/www"> Order Deny,Allow Deny from all Allow from 127.0.0.1 </Directory> </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@homemail.net DocumentRoot "D:/websrc/www/project1" ServerName project1.dev ServerAlias project1.dev www.project1.dev Options Indexes FollowSymLinks <Directory "D:/websrc/www/project1"> AllowOverride All Order Deny,Allow Allow from 127.0.0.1 Allow from 192.168.2 </Directory> </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@homemail.net DocumentRoot "D:/websrc/www/project2" ServerName project2.dev ServerAlias project2.dev www.project2.dev Options Indexes FollowSymLinks <Directory "D:/websrc/www/project2"> AllowOverride All Order Deny,Allow Allow from 127.0.0.1 Allow from 192.168.2 </Directory> </VirtualHost> 

You will need to change the directory names to suit your situation.

Also remember to add your hostnames to your HOSTS file

C: \ Windows \ system32 \ Drivers \ Etc \ hosts

 > 127.0.0.1 project1.dev > 127.0.0.1 project2.dev 

Virtual hosts are best configured somewhere outside of the / wamp / www folder structure, in my opinion. See above in the example that I used d: \ websrc \ www \ project1

You start virtual hosts using the project1.dev file directly in the browser address field.

If you want to see your virtual hosts on the wamp homepage, follow these steps:

create a folder?: / wamp / vhosts In this folder, create files named so: project1.dev.conf project2.dev.conf ... etc.

They do not require any content, just the correct name matches virtual host names

They will then be displayed on the wamp homepage under the TITLE section of your virtual hosts, and you can click on them to launch them.

+2
source

Hi developers, I'm sorry, but I'm not here to answer you bro. I also have a question that bothers me. I need your help guys, I created a virtual host in the www folder, but when I put it in my url, it tells me the index / and displays an html file with jpg images, but cannot show them in the browser, which is an index / expression and what can I do to fix this problem so that my page can be displayed in advance thanks.

0
source

All Articles