我将域 www.supergenscript 托管在仅在建索引页位于其中的云服务器上已上传.目前没有.htaccess文件,因此我创建了.htaccess文件,并使用filezilla将其上传到服务器中.我想将我的网站从http自动重定向到https.这些是我的.htaccess文件的内容.
I have domain www.supergenscript hosted on a cloud server where only an under construction index page is uploaded. There was no .htaccess file present so I created a .htaccess file and uploaded it in the server using filezilla. I want to redirect my website from http to https automatically. These are the contents of my .htaccess file.
RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteCond %{HTTP_HOST} ^(www\.)?supergenscript\ RewriteRule ^(.*)$ www.supergenscript/$1 [R=301, L]除这些代码行外,没有其他内容.我希望这能正常工作,但这不会自动将我的域重定向到https.请帮助我.
Nothing else except these lines of codes is written there. I expected this to work but this is not redirecting my domain to https automatically. Please help me with this.
推荐答案您可以使用:
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) %{HTTP_HOST}%{REQUEST_URI} [R=301,L] </IfModule>将.htaccess上载到您的根目录.
Upload the .htaccess to your root directory.
第1行:检查模块-mod_rewrite已激活.
Line 1: Checks the module - mod_rewrite is activated.
第2行:启用重写引擎.
第3行:检查HTTPS协议是否已打开,如果未打开,则执行第4行的内容.
Line 3: Checks if HTTPS-Protocol is switched on, if not then execute the contents of line 4.
第4行:通过状态代码301 =(永久重定向)将所有请求重定向到HTTPS.
Line 4: Redirects all requests to HTTPS via status code 301 = (permanent redirect).
第5行:关闭-mod_rewrite!
Line 5: Close - mod_rewrite!
更多推荐
.htaccess无法将http重定向到https
发布评论