小编Bha*_*rat的帖子

Apache 总是将 http 重定向到 https

我在 Ubuntu 12.04 上运行 Apache 2.4.7。我有一个网站http://bharatkrishna.net/,这是在我家的一台机器上运行的。我在路由器上转发了端口 80 和 443。

如您所见,当您访问http://bharatkrishna.net/ 时,它会自动重定向到https://bharatkrishna.net/

我不希望它被重定向到整个站点的 https。我本来打算只针对特定的子 URL 执行此操作。IE。就像只有http://bharatkrishna.net/login应该是 https,其余的应该是 http。我该怎么做?

这是我通过在线阅读一些教程在 Apache 上设置 SSL 的方法:

• 在 /etc/apache2/sites-enabled/ 打开 SSLEngine,设置证书位置

<IfModule mod_ssl.c>
        <VirtualHost _default_:443>
                ServerAdmin webmaster@localhost                                                                                                                                                                                               
                DocumentRoot /var/www/html/

                #LogLevel info ssl:warn                                                                                                                                                                                                       

                ErrorLog ${APACHE_LOG_DIR}/error.log
                CustomLog ${APACHE_LOG_DIR}/access.log combined                                                                                                                                                                               

                #   SSL Engine Switch:                                                                                                                                                                                                        
                #   Enable/Disable SSL for this virtual host.                                                                                                                                                                                 
                SSLEngine on

                SSLCertificateFile      /etc/apache2/ssl/www_bharatkrishna_net.crt
                SSLCertificateKeyFile   /etc/apache2/ssl/bharatkrishna.net.key

                SSLCACertificatePath /etc/ssl/certs/
                SSLCACertificateFile /etc/apache2/ssl/bundle.crt

....
....

        </VirtualHost>
</IfModule>
Run Code Online (Sandbox Code Playgroud)

• 运行以下命令:

sudo a2enmod …
Run Code Online (Sandbox Code Playgroud)

https apache-2.4

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

apache-2.4 ×1

https ×1