Cannot Redirect Root/Apex Domain without Breaking Admin Panel

No matter how I attempt to create a redirect for the root url to our main URL, it breaks our admin panel in two ways.

  1. If I go to exampledotcom/admin I get redirected to our main URL.
  2. If I go to exampledotcom/admin/ I get redirected to our “subdomain” extension for the main URL i.e. exampledotmainurldotcomadminindex.php rather than exampledotcomadminindex.php

It wouldn’t be an issue if the second way it was broken still allowed me to log in, but it throws me into a login loop with no way out. I tried 4 different ways to redirect.

  1. A simple index.php redirect:
<?php header('Location:httpsmainurldotcom'); ?>
  1. Via .htaccess

    RewriteCond %{HTTP_HOST} ^exampledotcom$
    RewriteRule ^/?$ httpswwwmainurldotcom [R=301,L]
  1. Using the Plugin “YOURLS Redirect Index

  2. Using cPanel domain level redirect with wildcard redirects disabled.

Each way produced the same results. Any help would be appreciated.

Just bumping, I can make a bug report on the repo instead if this is an unknown issue.

Hello @GameSyns, thanks for your message.

All the ways you tried should work well (at least 1 & 2).
Be sure:

  • Your browser didn’t cache the initial redirection.
  • Your server config is not overwritten elsewhere.

The most simple way (but not the cleanest) with a raw installation is way 1. index.php is only use if the URL is at the directory root. If it does not work, there is a mistake in the server config on your side.