【发布时间】:2020-10-07 06:52:53
【问题描述】:
我的网络服务器上公共文件的根目录中有一个 htaccess 文件:
Header set Content-Security-Policy: upgrade-insecure-requests
DirectoryIndex index.html index.php parking-page.html
RewriteEngine on
# Force www
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Force SSL
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L,NE]
Options -Indexes
ErrorDocument 404 https://%{HTTP_HOST}/index.php
# for JWT auth
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
# end for JWT auth
我在 /blog 上安装了一个 Wordpress 博客,Wordpress 在该文件夹中创建了一个 .htaccess 文件:
# BEGIN WordPress
# The directives (lines) between `BEGIN WordPress` and `END WordPress` are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<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
我注意到,当我访问 http://example.com/blog 时,它会将我重定向到 https://www.example.com/index.php ,而它应该转到 https://www.example.com/blog 。 其他页面,例如http://example.com/contact-us,成功重定向到https://www.example.com/contact-us
更新:
【问题讨论】: