Login to Wordpress Admin via IP but not domain name

March 26, 2017 291 views
WordPress Ubuntu 16.04

I can login to wp dashboard using my ip address, but not my domain name, i.e:

12.345.67.89/wp-admin works ok
mydomain.com/wp-admin doesn't work

I just get taken back to the login page again when I enter correct login details.
(If I enter incorrect ones I get the usual error message).

I'm assuming it is some settings somewhere, but I don't know where.

I've edit my wp-config file:

define('WPHOME','http://mydomain.com');
define('WP
SITEURL','http://mydomain.com');

Is there something else I'm missing?

2 Answers

@robertjamespeacock

Using define() to set the constants should be all that's required, unless the Apache configuration is using the IP as ServerName instead of your actual domain.

You can check the file in /etc/apache2/sites-available that corresponds to your website to see how the VirtualHost is setup. You'll want to check ServerName and ServerAlias to see what is listed as the domain/IP.

Also make sure your domain is setup with the correct A entry pointing to your server IP.

Beyond that, clear your cookies/cache before trying to login again, just to make sure that isn't the issue.

Thanks for the tips.

I did all that and I've managed to get it working. I think in the end it was something to with the write permissions for .htaccess.

Have another answer? Share your knowledge.