I have a subdomain:
https://blog.example.com/
I forcibly redirects to subdirectory:
https://www.example.com/blog
By changing site URL and some RewriteRule
on .htaccess
.
Now the website and admin works fine except a small issue like when I tried to click save button on settings page (eg: Setting > Writing ) the site redirects to main domain:
https://www.example.com/wp-admin/options-writing.php?settings-updated=true
/blog
is missing in the URL and end up in to main website 404 page.
My .htaccess file looks like :
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Host}i ^example\.com
RewriteCond %{HTTP_HOST} ^blog\.example\.com$
RewriteRule ^/?(.*)$ https://www.example.com/blog/$1 [L,R=301,NC]
RewriteCond %{HTTP:X-Forwarded-Server}i !^www\.example\.com
RewriteCond %{HTTP_HOST} ^blog\.example\.com$
RewriteRule ^/?[0-9]{4}/[0-9]{2}/(.*)$ https://www.example.com/blog/$1 [L,R=301,NC]
RewriteCond %{HTTP:X-Forwarded-Server}i !^www\.example\.com
RewriteCond %{HTTP_HOST} ^blog\.example\.com$
RewriteRule ^/?(.*)$ https://www.example.com/blog/$1 [L,R=301,NC]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^/?(.*)$ https://www.example.com/blog/$1 [L,R=301,NC]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
When click save button, console have an error message:
/wp-admin/options-general.php?settings-updated=true:1 GET https://www.example.com/wp-admin/options-general.php?settings-updated=true 404 ()
Can anybody help to figure this out?
Updated working .htaccess (according to 1st answer) :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^/?(.*)$ https://www.example.com/blog/$1 [L,R=301,NC]
</IfModule>
My wordpress address and site address are:
WordPress Address (URL) = /blog
Site Address (URL) = https://www.example.com/blog
RewriteRule
are you using in your.htaccess
? Pleaseedit
your question with the rules you are using.