admin管理员组文章数量:1122846
I have a subdomain:
/
I forcibly redirects to subdirectory:
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:
.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\
RewriteCond %{HTTP_HOST} ^blog\.example\$
RewriteRule ^/?(.*)$ /$1 [L,R=301,NC]
RewriteCond %{HTTP:X-Forwarded-Server}i !^www\.example\
RewriteCond %{HTTP_HOST} ^blog\.example\$
RewriteRule ^/?[0-9]{4}/[0-9]{2}/(.*)$ /$1 [L,R=301,NC]
RewriteCond %{HTTP:X-Forwarded-Server}i !^www\.example\
RewriteCond %{HTTP_HOST} ^blog\.example\$
RewriteRule ^/?(.*)$ /$1 [L,R=301,NC]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteCond %{HTTPS} off
RewriteRule ^/?(.*)$ /$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 .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 ^/?(.*)$ /$1 [L,R=301,NC]
</IfModule>
My wordpress address and site address are:
WordPress Address (URL) = /blog
Site Address (URL) =
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
Share
Improve this question
edited Sep 21, 2016 at 11:59
Muhammad Riyaz
asked Sep 20, 2016 at 13:15
Muhammad RiyazMuhammad Riyaz
1482 silver badges13 bronze badges
2
|
1 Answer
Reset to default 0From looking at your .htaccess
, it looks like your has too many rules overlapping each other. Do the following instead:
- Keep a backup of your current
.htaccess
if you need to go back to it - Delete your
.htaccess
form the server, WordPress should automatically create a fresh one for you - 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
本文标签: htaccessSite redirects to wrong url when saving settings
版权声明:本文标题:htaccess - Site redirects to wrong url when saving settings 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736290956a1928622.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
RewriteRule
are you using in your.htaccess
? Pleaseedit
your question with the rules you are using. – Ethan Rævan Commented Sep 20, 2016 at 13:28