Search code examples
wordpressvirtualhost

Wordpress not working when using Apache virtual hosts


I currently use virtual hosts on my computer so that I can manage multiple sites on my computer.

Currently, I use c:/vhosts/php (default localhost) for regular PHP development, c:/vhosts/BTS for Wordpress, and c:/vhosts/cake for CakePHP development. (see below).

Now when I launch my WAMPP and go to http://BTS, it loads the index page but nothing else loads fine. When trying to click on the links, it links to http://localhost/xxxxx instead of http://BTS/xxxxx. What am I missing here? I don't want the server to access localhost since I'm using localhost for other projects. Please help.

<VirtualHost *:80>
DocumentRoot c:/vhosts/php
ServerName localhost
</VirtualHost>

<VirtualHost *:80>
DocumentRoot c:/vhosts/BTS
ServerName BTS
</VirtualHost>

<VirtualHost *:80>
DocumentRoot c:/vhosts/cake
ServerName cake
</VirtualHost>

Solution

  • Go into your MySQL database (thru phpmyadmin or whatever) and look for the following fields

    In the wp_options table, change

    siteurl
    home
    

    To http://BTS instead of localhost.

    This will update all your links in wordpress.