Post Date: December 5, 2020
Last Updated: November 20, 2026
Introduction
Sometimes, when accessing a WordPress website using its www domain, visitors may unexpectedly get redirected to the WordPress login page or /wp-admin instead of the website homepage.
For example, when accessing:
The browser may redirect to:
https://example.com/wp-login.php?redirect_to=https%3A%2F%2Fexample.com%2Fwp-admin%2F&reauth=1
This can happen because of incorrect WordPress URL settings, conflicting redirect rules, or an issue with the website’s .htaccess configuration.
In this article, we will explain how to troubleshoot this issue by checking the standard WordPress .htaccess configuration and adding a redirect rule to redirect the www version of the domain to the non-www version.
Prerequisites
Before making any changes, ensure that you have:
- Access to your website’s hosting control panel or server.
- Access to the WordPress website files.
- Permission to edit the
.htaccessfile. - A backup of the existing
.htaccessfile. - A valid SSL certificate covering the domain and its
wwwsubdomain if HTTPS is enabled.
Implementation
Step 1: Check the Standard WordPress .htaccess Configuration
First, log in to your hosting control panel and open the File Manager.
Navigate to the WordPress installation directory, usually the public_html folder.
Locate the .htaccess file.
If the file is not visible, enable the option to display hidden files in File Manager.
Before making changes, download a copy of the existing .htaccess file as a backup.
Check whether the file contains the standard WordPress rewrite configuration:
# 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
This is the standard WordPress rewrite configuration used to direct requests to the WordPress front controller when the requested file or directory does not exist.
If the configuration is missing or incorrect, restore the standard WordPress rules after backing up the existing file.
Step 2: Add the www to Non-www Redirect Rule
After verifying the standard WordPress configuration, add the following redirect rules to the .htaccess file.
Place them above the # BEGIN WordPress section:
# Force non-www and HTTPS
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L]
</IfModule>
Replace example.com with your actual domain name.
Explanation:
RewriteEngine On: Enables Apache URL rewriting.RewriteCond %{HTTP_HOST}: Checks the requested hostname.^www\.example\.com$: Matches thewwwversion of your domain.[NC]: Makes the hostname comparison case-insensitive.RewriteRule: Redirects the request to the non-www HTTPS version.[R=301,L]: Issues a permanent redirect and stops processing subsequent rewrite rules.
For example:
| Original URL | Redirect destination |
|---|---|
http://www.example.com | https://example.com |
https://www.example.com | https://example.com |
https://www.example.com/about | https://example.com/about |
The redirect preserves the requested path and query string.
Note: The original screenshot uses an HTTP destination. The updated configuration uses HTTPS so that visitors are redirected to the secure canonical website URL.
Is your WordPress website redirecting visitors to the wrong page? Incorrect URL settings, conflicting rewrite rules, and plugin configurations can affect website accessibility and user experience. Our WordPress specialists can help identify the cause and restore the correct redirects. Get expert WordPress support.
Step 3: Verify the WordPress Website URLs
If the redirect issue continues, check the WordPress URL settings.
- Log in to the WordPress dashboard.
- Navigate to Settings → General.
- Locate the following fields:
- WordPress Address (URL)
- Site Address (URL)
- Ensure both fields use the same preferred domain format.
For example, if you want to use the non-www version:
WordPress Address (URL): https://example.com Site Address (URL): https://example.com
Save the changes if necessary.
Note: If you cannot access the WordPress dashboard, check the WP_HOME and WP_SITEURL definitions in wp-config.php and the corresponding home and siteurl values in the WordPress database. Back up the configuration or database before changing them.
Step 4: Clear Website and Browser Cache
After updating the redirect configuration:
- Clear the WordPress caching plugin cache.
- Clear any server-level caching.
- Purge CDN or reverse-proxy cache if applicable.
- Open a private or incognito browser window.
- Test the website using the
wwwdomain.
This helps rule out cached redirects and outdated website responses.
Step 5: Verify the Redirect
Open your browser and enter:
The website should redirect to:
You can also verify the redirect using the following command:
curl -I https://www.example.com
A successful redirect should return a response similar to:
HTTP/2 301 location: https://example.com/
To follow the redirect and inspect the final response, run:
curl -IL https://www.example.com
If the website loads correctly using the non-www domain, the redirect configuration is working as expected.
Additional Troubleshooting: Website Still Redirects to wp-admin
If the issue continues after updating .htaccess, investigate the following:
1. Check WordPress URL Configuration
Incorrect WP_HOME or WP_SITEURL values can cause WordPress to redirect visitors to an unexpected hostname or URL.
Verify that the configured URLs match your preferred domain and HTTPS scheme.
2. Check WordPress Plugins
Security, redirection, caching, and login-related plugins may introduce additional redirects.
Temporarily disable recently installed or updated plugins to identify whether one is causing the issue. Take a backup before making changes.
3. Check Other Redirect Rules
Review the following locations for conflicting redirect configurations:
.htaccess- Apache virtual host configuration
- Nginx configuration, if used
- CDN or reverse-proxy settings
- WordPress redirection plugins
Avoid configuring multiple conflicting redirects for the same domain.
4. Check SSL Configuration
Ensure that the SSL certificate covers both:
example.comwww.example.com
Both hostnames must resolve to the correct hosting environment and support HTTPS before using the redirect configuration.
5. Check WordPress Login and Authentication
If the homepage works on the non-www domain but redirects to /wp-admin only when using the www domain, review authentication cookies, WordPress login settings, and security plugins.
A redirect to wp-login.php with a redirect_to parameter can indicate that WordPress is attempting to authenticate a request to a protected administrative page. It does not necessarily mean that .htaccess is the root cause.
Conclusion
A WordPress domain redirecting from the www version to the /wp-admin login page can be caused by incorrect rewrite rules, inconsistent WordPress URL settings, or conflicting redirect configurations.
Checking the standard WordPress .htaccess configuration and adding the appropriate www-to-non-www redirect rule can resolve hostname-related redirect issues.
If the problem continues, review WordPress URL settings, plugins, caching, SSL configuration, and other server-level redirect rules to identify the underlying cause.
Frequently Asked Questions (FAQs)
1. Why does my www domain redirect to wp-admin?
This can happen because of incorrect WordPress URL settings, conflicting .htaccess rules, redirect plugins, or authentication-related configurations.
2. How do I redirect www to non-www in WordPress?
You can add an Apache rewrite rule to your .htaccess file that redirects requests from www.example.com to example.com using a permanent 301 redirect.
3. What is the standard WordPress .htaccess configuration?
The standard configuration uses Apache’s mod_rewrite module to direct requests to index.php when the requested file or directory does not exist.
4. Will changing .htaccess affect my WordPress website?
Incorrect .htaccess rules can cause redirect loops, 404 errors, or website access issues. Always back up the existing file before making changes.
5. How can I check whether my www redirect is working?
Run curl -I https://www.example.com and check whether the response contains a 301 status code and a Location header pointing to your preferred non-www domain.
References
- WordPress Developer Documentation – Logging In
- WordPress Developer Documentation – Migrating WordPress
Related Articles
Get Expert Support for WordPress and Website Configuration
Resolving redirect problems often requires checking multiple layers, from WordPress settings and Apache rewrite rules to server-level configurations. Pheonix Solutions can help you keep your website accessible and properly configured through:
- WordPress development and troubleshooting: Website development services to resolve website functionality, URL, and configuration issues.
- Server and hosting optimization: DevOps and cloud services for Apache configuration, hosting environments, and server administration.
- Ongoing technical support: Software maintenance and support to maintain website stability, security, and performance.
Need Assistance?
Still experiencing unexpected redirects on your WordPress website? Need help reviewing .htaccess rules, correcting domain configurations, or resolving Apache rewrite issues?
The technical team at Pheonix Solutions can help diagnose website configuration problems, troubleshoot server-level issues, manage website migrations, and maintain your hosting environment.
Contact our team to discuss your website support requirements.
