skip to Main Content

I have a problem with my WordPress website. It runs perfectly on localhost but when I try to add a virtual host to it, I can’t access the admin panel. I am using xampp.

I have tried to access it by typing http://localhost/commerce/wp-admin and me.commerce.loc/wp-admin in the search bar but none of those work. Both return Oops! That page can’t be found..

Here is the code I wrote in my httpd-vhosts.conf file:

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/commerce"
    ServerName webmaster.loc
</VirtualHost>

This is my .htaccess file:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

My code in hosts file:

# localhost name resolution is handled within DNS itself.
127.0.0.1       localhost 
::1             localhost
127.0.0.1       me.commerce.loc

2

Answers


  1. Chosen as BEST ANSWER

    I have done some research and it turns out I had to change siteurl and home fields in my wp_options table. After setting them to my v-host address it works perfectly.


  2. You can also override siteurl and homeurl in wp-config.php.

    define('WP_HOME','http://me.commerce.loc');
    define('WP_SITEURL','http://me.commerce.loc');
    

    Please this post for more detail https://help.dreamhost.com/hc/en-us/articles/214580498-How-do-I-change-the-WordPress-Site-URL-

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search