I am redeveloping a WordPress site, and have followed this procedure to copy it to my local machine:

  1. Copy all files from server to localhost server subdirectory
  2. Edit wp-config.php with my local database settings
  3. Copy server SQL to local database
  4. Edited my hosts file like this:

127.0.0.1 www.thesiteiamredeveloping.com 127.0.0.1 thesiteiamredeveloping.com

The problem I have is that when I now go to http://thesiteiamredeveloping.com in my browser, I just get shown an "Index of /" page that lists all the subdirectories in my localhost server (which includes the thesiteiamredeveloping.com subdirectory).

How can I make it so that http://thesiteiamredeveloping.com points to the required subdirectory rather than the server's root directory??

NB - The localhost server I'm using is EasyPHP DevServer 14.1 VC11 - on Windows 7.

Update

I added this to my httpd-vhosts.conf file:

<VirtualHost *:80>
  DocumentRoot "P:/Program Files/EasyPHP-DevServer-14.1VC11/data/localweb/jhtest12.com"
  ServerName jhtest12.com
</VirtualHost>

And I added this to my hosts file:

127.0.0.1 www.jhtest12.com
127.0.0.1 jhtest12.com

Then I created an index.html file in the P:\Program Files\EasyPHP-DevServer-14.1VC11\data\localweb\jhtest12.com folder and restarted the server, but when I try to load http://jhtest12.com in my browser, it take ages to load before showing the same directory page.

Any ideas??

Update 2

The last section of my httpd.conf file is...

# Virtual Hosts
## Virtualhost localweb
<VirtualHost 127.0.0.1>
    DocumentRoot "P:/Program Files/EasyPHP-DevServer-14.1VC11/data/localweb"
    ServerName 127.0.0.1
    <Directory "P:/Program Files/EasyPHP-DevServer-14.1VC11/data/localweb">
        Options FollowSymLinks Indexes
        AllowOverride All
        Order deny,allow
        Allow from 127.0.0.1
        Deny from all
        Require all granted
    </Directory>
</VirtualHost>
Include ../../data/conf/apache_virtual_hosts.conf

...so I have moved the VirtualHost directive from my httpd-vhosts.conf file to the apache_virtual_hosts.conf file, but I'm still having no luck.

In fact, it seems nearly all requests to localhost are not being served correctly - despite me changing all the settings back to their original state, restarting the server, running CCleaner and restarting my computer. What could have broken??

The web server, apache in your case, is listening on port:80 on your localhost.

You can tell apache to serve one particular folder based on request name (let's call it virtual host).

To teach apache about that, explore your apache folder (apache/conf/extra/httpd-vhosts.conf) and add :

<VirtualHost *:80>
  DocumentRoot "/www/example1"
  ServerName www.example.com
</VirtualHost>

more info https://httpd.apache.org/docs/2.4/vhosts/examples.html

  • Many thanks for this answer, but I'm afraid it hasn't worked. Please see the Update section in my question. – ban-geoengineering Jan 13 '16 at 13:22
  • well, servername specifies that a site with that name exists and should be served; it should be served with files belonging to the folder specified within documentroot. first i would try to point servername to a domainname (thesiteiamredeveloping.com), not to 127.0.0.1, then i'd remove all <Directory> configurations, i.e deny allow (you can add them later to an .htaccess file in the wordpress directory) then check that the document root is the folder containg your wordpress config.php file. Of course stop restart server after every modification. – urka_mazurka Jan 13 '16 at 14:22

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.