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
I have done some research and it turns out I had to change
siteurl
andhome
fields in mywp_options
table. After setting them to my v-host address it works perfectly.You can also override
siteurl
andhomeurl
inwp-config.php
.Please this post for more detail https://help.dreamhost.com/hc/en-us/articles/214580498-How-do-I-change-the-WordPress-Site-URL-