网站从http迁移到https

Migration of website from http to https

本文关键字:https 迁移 http 网站      更新时间:2024-02-11

我刚刚将我的网站从http移动到https。图像、javascript和css文件的状态为403(Forbidden)。我正在使用php代码点火器。我缺少的是什么?

将其添加到.htaccess中,以将整个网站移动到https

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^example'.com [NC]
    RewriteCond %{SERVER_PORT} 80 
    RewriteRule ^(.*) https://example.com/$1 [L,R=301]
</IfModule>

其中example.com是您自己的域。您可以使用本地ip或localhost

对于localhost

<IfModule mod_rewrite.c>    
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^localhost [NC]
    RewriteCond %{SERVER_PORT} 80 
    RewriteRule ^(.*) https://localhost/$1 [L,R=301]
</IfModule>

以上解决方案适用于您的域的根目录。如果您需要文件夹式

<IfModule mod_rewrite.c>
    RewriteEngine On 
    RewriteCond %{HTTP_HOST} !^example'.com [NC]
    RewriteCond %{SERVER_PORT} 80 
    RewriteCond %{REQUEST_URI} folder 
    RewriteRule ^(.*)$ https://example.com/folder/$1 [R,L]
</IfModule>