skip to Main Content

I’m no expert in WordPress but have a fair amount of knowledge as I’ve used it for years.

My problem is that I cannot access the admin panel for a specific site because it has been redirected to a different domain.

When I try access the admin panel at www.XXX.com/wp-admin, the site redirects to the domain www.YYY.com/wp-admin.

I believe there is a way to modify the .htaccess file to exclude redirects for the admin panel url, but I have not been able to make this work.

The redirect rule currently looks like this in the .htaccess file

# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
# Redirect to YYY.com (except wp-admin)
RewriteCond %{HTTP_HOST} ^XXX.com.au$ [OR]
RewriteCond %{HTTP_HOST} ^www.XXX.com.au$
RewriteRule ^(?!wp-admin/)(.*)$ "https://YYY.com.au/$1" [R=301,L]

Can any one shed some light on how to make this work?

Tried modifying

RewriteRule ^(?!wp-admin/)(.*)$ "https://YYY.com.au/$1" [R=301,L]

With no success.

2

Answers


  1. First of all you shouldnt delete .htaccess file. Instead, create a new .htaccess file in the root directory of your WordPress installation if one does not already exist.

    Add the Following Lines to the .htaccess File: Reference URL https://developer.wordpress.org/advanced-administration/server/web-server/httpd/#basic-wp

    # 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
    

    Add the following lines the wp-config.php file: Reference URL https://developer.wordpress.org/advanced-administration/upgrade/migrating/#changing-the-site-url

    define('WP_HOME', 'http://yoursite.com');
    define('WP_SITEURL', 'http://yoursite.com');
    

    Go to your WordPress admin panel (wp-admin) and see if the redirect issue resolved.

    After fixing the issue, you may remove the added lines in the wp-config.php file if they’re no longer needed:

    // Remove these lines if no longer needed
    // define('WP_HOME', 'http://yoursite.com');
    // define('WP_SITEURL', 'http://yoursite.com');
    

    If the above method does not resolve the issue, you might want to try the following additional Solution:

    1. In your WordPress admin panel, go to Settings > Permalinks.
    2. Select your preferred permalink structure and save changes.

    Note: now go to wp-admin and hopefully you’re redirect problem will be fixed.
    dont forget to remove last code from wp-config after fixing youre issue.

    Login or Signup to reply.
  2. I would suggest to leave the .htaccess file as is.

    If you have access to phpMyAdmin, then follow the steps below.

    1. Log into your phpMyAdmin
    2. Select your database
    3. Go to the _options table (if your table prefix is wp, then it will be wp_options)
    4. Edit "siteurl" and "home" to http://yourwebsite.com

    That should solve the issue.

    As @theaminul suggested, you can also add the home and siteurl in your config.php but editing the values in the table should allow you to access wp_admin.

    Once you are logged into your wp_admin, reset and save your permalinks.

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