尝试将我的网站从 http 重定向到 https,但它不起作用...网站同时在 http 和 https 上打开。
这是我目前在 htaccess 文件中使用的代码部分,但此代码不会自动使用 https 重定向网站,并使网站同时使用 http 和 https 打开。这太令人困惑了。
------------------------------------------------
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteCond %{HTTPS} off
RewriteCond %{HTTP:X-Forwarded-SSL} !on
RewriteCond %{HTTP_HOST} ^www\.surffares\.com$
RewriteCond %{REQUEST_URI} !^/\.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/(?:\ Ballot169)?
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteRule ^/?$ "https\:\/\/www\.surffares\.com\/" [R=301,L]
------------------------------------------------------------------------
但是这段代码不起作用......
这是 godaddy 建议在 htaccess 中用于自动重定向的代码, 但此代码仅加载首页,自动重定向首页 仅页面但没有打开其他页面,当我单击任何其他页面时, 它向我显示未找到错误。
---------------------------------------------------------------------
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^(www\.)?coolexample\.com
RewriteRule ^(.*)$ https://www.coolexample.com/$1 [R,L]
--------------------------------------------------------------------
Godaddy 客户支持告诉您需要在 .htaccess 中提取内页。
我如何自动将我的网站从 http 重定向到 https,并提取网站的所有内页。
注意:我的网站是 php mvc laravel
我已经快速构建了一个配置来测试这个场景。在 Apache VirtualHost 中,您需要使用 AllowOverride 确保 apache 尊重 htaccess 文件。
这是 VirtualHost 中的配置:
<VirtualHost *:80>
ServerName test.com
DocumentRoot /var/www
<Directory "/var/www>
Require all granted
AllowOverride all
</Directory
</VirtualHost>
然后,在 /var/www/.htaccess 中,定义以下内容:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]
希望有帮助。
乔
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{HTTP_HOST} ^(www\.)?geoffreystevens\.com
RewriteRule ^(.*)$ https://www.geoffreystevens.com/$1 [R,L]
from madewithlove website it says This condition was not met. How do I fix
the code (or does it need to be fixed. This is for Linux in Godaddy. I bought
an SSL and this is what they sent me for the htaccess. But now I see 2
errors.
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.geoffreystevens.com/$1 [R,L]