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
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
Add the following lines the wp-config.php file: Reference URL https://developer.wordpress.org/advanced-administration/upgrade/migrating/#changing-the-site-url
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:
If the above method does not resolve the issue, you might want to try the following additional Solution:
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.
I would suggest to leave the .htaccess file as is.
If you have access to phpMyAdmin, then follow the steps below.
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.