简体   繁体   English

Http 到 Https 重定向问题?

[英]Http to Https redirection issue?

# Redirect HTTP to HTTPS 
RewriteCond %{HTTPS} !=on RewriteRule (.*) 
https://%{SERVER_NAME}/$1 [R,L]
# 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

This is my websites htaccess code.这是我的网站 htaccess 代码。 I want to redirect my site http to https.I tried some code but not working我想将我的网站 http 重定向到 https。我尝试了一些代码但没有工作

Use the following code if your site in root of the server.如果您的站点位于服务器的根目录中,请使用以下代码。

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE] 

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

OR assuming from your code its in /blog/ folder.或者假设您的代码位于 /blog/ 文件夹中。 Using the following code instead.改用以下代码。

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE] 

<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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM