Can’t remove a 302 redirect that was created automatically after changing domain
So I inherited a multisite instance and I’ve changed the domain from example.co to example.com.
A 302 redirect that takes you from the old domain to the new domain was automatically created. This is fine on paper, but the problems are:
- I need it to be a 301 redirect for SEO purposes
- The redirect strips away URL paths, so mydomain.co/path takes you to mydomain.com
Trying to override the redirect with something like the code below creates a redirect loop.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.co [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.co [NC]
RewriteRule ^(.*)$ https://example.com/$1 [L,R=301,NC]
I want to find this redirect so I can modify it. So far I’ve:
- Deleted my browser cache with every test
- Changed my .htaccess to the vanilla WordPress file. Breaking the file breaks my site, so I know it’s working
- Disabled all the plugins even by renaming the plugins folder
- Checked my php files for redirects
- Reverted to the old domain. This stopped the redirection. Interestingly, it kept redirecting from http to https. What could be handling this?
This is my current .htaccess file:
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*.php)$ $2 [L]
RewriteRule . index.php [L]
Where else could the redirect be located? I’m sure I’m overlooking something obvious. Thanks in advance!
Leave an answer