2015-01-07 24 views
0

我在Ubuntu上运行Apache 2.4.7,我想重定向流量从http://到https://所有的URL。我想在5秒后显示一个页面,其中包含更新书签和重定向的注释。重定向从http到https在apache显示原始网址与参数

例如,如果装载http://example.com/one/two/three?param=x&param2=y,我想显示一个页面,上面写着这样的:

请更新您的书签以指向: https://example.com/one/two/three?param=x&param2=y你会 在5秒内重新定向。

我想知道是否有一个简单的方法来做到这一点与Apache指令,也许一个单一的.html文件作为上述页面的模板。

回答

0

如果在同一领域,要做到这一点的最好方法是使用下面mod_rewrite使用您的虚拟主机配置

<VirtualHost *:80> 
    ServerName example.com 
    RewriteEngine on 
    RewriteCond %{SERVER_PORT} !^443$ 
    RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R=301,L] 
</VirtualHost> 

这会自动将用户重定向到https浏览的网站有一个正确的请求URI 。用户不需要更新他们的书签。
祝你好运!

+0

这看起来像一个很好的策略,但我特别想知道如何实现5秒延迟的重定向页面 – nonagon

+0

你可以做的是host [redirect.html](http://webmaster.iu.edu/tools -and-guides/maintenance/redirect-meta-refresh.phtml)并将用户重定向到http:// example.com/redirect.html。您可以通过编辑上面答案中的配置来实现此目的。 'RewriteEngine on''RewriteRule^http://example.com/redirect.html [R = 301,L]' – slash

+0

我可以显示它们在redirect.html中加载的原始URL吗? – nonagon