我试图使用XAMPP将HTTP重定向到HTTPS。
我已经在多个网站上看到了所有的问题和多个答案,推荐这个网站:https://robsnotebook.com/xampp-ssl-encrypt-passwords
我就是这样做的:
我不评论这句话:
LoadModule rewrite_module modules/mod_rewrite.so在C:/xampp/apache/config/httpd.conf中删除前面的#。
然后我在C:/xampp/apache/config/extra/httpd-xampp.conf里面输入了这个
<IfModule mod_rewrite.c>
RewriteEngine On
# Redirect /xampp folder to https
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} xampp
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [R,L]
# Redirect /phpMyAdmin folder to https
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} phpmyadmin
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [R,L]
# Redirect /security folder to https
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} security
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [R,L]
# Redirect /webalizer folder to https
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} webalizer
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [R,L]
</IfModule>我三次检查是否正确地完成了所有操作,保存了所有内容,并重新启动了XAMPP,但仍然无法重定向到HTTPS。请帮帮忙!
发布于 2017-02-13 18:33:56
我自己找到了答案,我已经安装了vhost,我不得不把
<IfModule mod_rewrite.c>
RewriteEngine On
# Redirect /xampp folder to https
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} xampp
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [R,L]
# Redirect /phpMyAdmin folder to https
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} phpmyadmin
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [R,L]
# Redirect /security folder to https
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} security
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [R,L]
# Redirect /webalizer folder to https
RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} webalizer
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [R,L]
</IfModule>在我希望在C:/xampp/apache/config/extra/httpd-vhosts.conf.中重定向的目录中
这在罗比笔记本的最后几行中解释了:
这种重定向需要记住的一点是,如果您有虚拟主机,则需要将重定向代码(带有RewriteCond和RewriteRule)放置在虚拟主机声明中,否则重定向将无法工作。
发布于 2022-06-01 03:28:56
步骤1: Config SSL用于xampp\apache\conf\extra\httpd-ssl.conf中的域
<VirtualHost 127.0.0.1:443>
DocumentRoot "/your/project/path"
ServerName yourdomain.com
SSLEngine on
SSLCertificateFile "/your/ssl/server.crt"
SSLCertificateKeyFile "/your/ssl/server.key"
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory "C:/xampp/apache/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
</VirtualHost>步骤2: Now配置将http重定向到xampp\apache\conf\extra\httpd-vhosts.conf中的https
<VirtualHost *:80>
RewriteEngine on
ServerName yourdomain.com
RewriteRule ^(.*) https://%{SERVER_NAME}$1 [R,L]
</VirtualHost>步骤3:重新启动Xampp
https://stackoverflow.com/questions/42209233
复制相似问题