Site redirects to wrong url when saving settings

From looking at your .htaccess, it looks like your has too many rules overlapping each other. Do the following instead:

  1. Keep a backup of your current .htaccess if you need to go back to it
  2. Delete your .htaccess form the server, WordPress should automatically create a fresh one for you
  3. Open your new .htaccess file and add the following between the <IfModule mod_rewrite.c> tag:

.

RewriteCond %{HTTP_HOST} ^blog\.example\.com$
RewriteRule ^/?(.*)$ https://www.example.com/blog/$1 [L,R=301,NC]

Your .htaccess should then look like the following:

# 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]
# Custom rewrite
RewriteCond %{HTTP_HOST} ^blog\.example\.com$
RewriteRule ^/?(.*)$ https://www.example.com/blog/$1 [L,R=301,NC]
</IfModule>
# END WordPress

Leave a Comment