Php HTTP到HTTPS重定向
我已经为站点添加了ssl,现在我想在htaccess中使用重定向 我在htaccess中有一个:Php HTTP到HTTPS重定向,php,wordpress,apache,.htaccess,Php,Wordpress,Apache,.htaccess,我已经为站点添加了ssl,现在我想在htaccess中使用重定向 我在htaccess中有一个: # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On #RewriteCond %{HTTPS} !=on #RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,QSA] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteCond %{HTTPS} !=on
#RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R,QSA]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
#开始WordPress
重新启动发动机
#重写cond%{HTTPS}=在…上
#重写规则^(.*)$https://%{HTTP_HOST}/$1[R,QSA]
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
我应该为重定向添加什么以及在哪里添加?
Th获取帮助在.htaccess文件中使用以下代码会自动将访问者重定向到站点的HTTPS版本:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
#开始WordPress
重新启动发动机
重写cond%{HTTPS}=在…上
重写规则^https://%{HTTP_HOST}%{REQUEST_URI}[L,R=301]
重写基/
重写规则^index\.php$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.php[L]
您应该将此.htaccess文件粘贴到项目根目录中。我应该将此代码粘贴到我的代码中的什么位置?可以吗<代码>#在RewriteCond%{HTTPS}上启动WordPress RewriteEngine关闭RewriteRule^(.*)$HTTPS://%{HTTP_HOST}%{REQUEST_URI}[L,R=301]RewriteBase/RewriteRule^ index\.php$-[L]RewriteCond%{REQUEST_FILENAME}-f RewriteCond%{REQUEST_FILENAME}-重写规则/index.php[L]@Narkomax,您需要将此添加到.htaccess文件中,并将该文件放在项目根文件夹中。我的意思是在我的所有代码之前或之后添加您键入的代码?我的意思是,这条小路在哪里piece@Narkomax刚刚更新了代码。请检查一下。