在托管中安装SSL。安装后尝试更改.htaccess中的重定向以获取https://使用greenpad锁符号但不能正常工作我试过的只是强制https在htaccess文件中它无效。下面是我的脚本中已经存在的.htaccess代码。因为我添加了RewriteRule ^(.*)$ https://
它无效。
<IfModule mod_rewrite.c>
RewriteEngine On
Options -Indexes
#RewriteBase /vrs7
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)/l([0-9]+)$ http://%{HTTP_HOST}/$1/l.$2 [R=301,L]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)/n([0-9]+)$ http://%{HTTP_HOST}/$1/n.$2 [R=301,L]
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)/p([0-9]+)$ http://%{HTTP_HOST}/$1/p.$2 [R=301,L]
#Adds trailing slash
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$
#RewriteRule ^(.*)$ $1/ [R=301,L]
#Remove trailing slash
#RewriteRule ^(.*)/$ $1 [R=301,L]
RewriteCond %{QUERY_STRING} ^(.*)?gclid=(.*) [OR]
RewriteCond %{QUERY_STRING} ^(.*)?utm_source=(.*) [OR]
RewriteCond %{QUERY_STRING} ^(.*)?fb_action_ids=(.*)
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ index.php?/$1 [L]
# Enforce www
RewriteCond %{HTTP_HOST} !^www\.
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^(.*)$ index.php?/$1 [PT,QSA]
ErrorDocument 404 /404.shtml
</IfModule>
我正在尝试这个自定义的PHP网站。这是度假租赁脚本,它没有选项在管理面板中添加https://。所以我试图在htaccess文件的帮助下实现它。
答案 0 :(得分:0)
将网站从http
重定向到https
:
RewriteEngine on
RewriteCond %{SERVER_NAME} =INSERTYOURSERVERNAMEHERE
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
将INSERTYOURSERVERNAMEHERE
替换为您的服务器名称,不含协议,即
RewriteCond %{SERVER_NAME} =example.com
答案 1 :(得分:0)
a2ensite default-ssl #this must be enable otherwise will show
AllowOverride All