Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php HTTP到HTTPS重定向_Php_Wordpress_Apache_.htaccess - Fatal编程技术网

Php HTTP到HTTPS重定向

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

我已经为站点添加了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 %{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刚刚更新了代码。请检查一下。