从Apache VirtualHost永久地将HTTPS重定向到HTTP

时间:2016-05-11 07:02:16

标签: apache http redirect https virtualhost

有很多关于将HTTP重定向到HTTPS的问题,如下所示:

    renderer = GetComponent<SpriteRenderer>();

    yClamp = Mathf.Abs(Camera.main.orthographicSize - 
        ((renderer.sprite.textureRect.height / renderer.sprite.pixelsPerUnit)/2f));

但我需要反过来,从HTTPS到HTTP,可能不使用mod_rewrite。那可能吗?

Apache版本:服务器版本:Apache / 2.4.7(Ubuntu)

我尝试了这个,但它不起作用:

<VirtualHost *:80>
    ServerName www.example.com
    Redirect / https://www.example.com/ 
</VirtualHost>

<VirtualHost *:443>
    ServerName www.example.com
    # ... SSL configuration goes here
</VirtualHost>

1 个答案:

答案 0 :(得分:-1)

这是适用于我的代码。

<VirtualHost *:80>
    ServerName example.com  
    ServerAlias www.example.com 
    DocumentRoot /var/www/html/example.com
</VirtualHost>

<VirtualHost *:443> ServerName example.com RewriteEngine on RewriteRule ^ http://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent] </VirtualHost>