Wordpress not working with domain name, redirect too many times

I registered a domain name with google’s registrar and I have it pointed to digital oceans name servers. This works fine, everything pings correctly.

I am trying to setup a wordpress site and the initial setup works. I can connect with the ip address or the domain name AND it will show the domain name in the address bar. Note that at this point the wordpress settings show the site and wordpress URL as the ip address. Despite this, the domain name still shows in the address bar, which is what I want.

If I make any theme change to the wordpress site, even if I switch out of and back into the initial theme (where everything was working), the address bar will no longer show the domain name. I can use the domain name to get to the website, but the URL will show the IP address, which I don’t want.

If I update the URL’s in the wordpress admin settings to be the domain name AND update the apache2 config to have servername and alias set to the domain name, then the website will not load. I get an “redirected you too many times” error. Note that the admin page: works fine, gives me the redirect issue.

I can switch back the wordpress settings URL’s to the ip address and the site works again, but it shows the ip address in the URL bar.

How can I solve this redirect issue and get the site to work with the domain name showing in the URL bar? Thanks!

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

I had a similar problem but caused by following advice by ServerPilot. Tip: Enter your server’s IP address as the app’s domain in order to preview the app in your browser using your server’s IP address.

This stopped me being able to access my website by the domain name because the wordpress install set its urls to the IP not the domain. So even after my dns propagated properly I got errors when entering the domain. Changing the url settings in wp-config got me access via the domain but I was unable to install multisite getting “Too many redirects” errors even with correct wpconfig and htaccess configuration. Starting from scratch with a new app and NOT following your tip worked fine. Good advice but it should say instead

Tip:Enter your server’s domain here, after app creation add the IP address as another of the app’s domain in order to preview the app in your browser using your server’s IP address.

I think I finally figured this out. I am pretty sure it was simply that I didn’t set the wordpress URL and site URL (in wordpress settings) to have ‘www.’ in front of the domain name.

I also switched to use google nameservers afterwards so I could use their email service.

For anyone future looking at this, including my future self, here is how I set up.

  • Domain registered through google domains
  • Using google’s nameservers, which is default. This allows you to use their email service if desired.
  • No domain needs to be setup with digital ocean.
  • Under Custom resource records in google domains, set @ A 1h ip.address.of.droplet and www CNAME 1h
  • Not sure if it’s required, but I edited the apache2 config file on the digital ocean server. This file for me was “/etc/apache2/sites-enabled/000-default.conf”. I added two lines: ServerName and ServerAlias