Apache2 重定向所有URL,Apache 000-default.conf中的URL除外

Apache2 重定向所有URL,Apache 000-default.conf中的URL除外,apache2,http-redirect,Apache2,Http Redirect,我需要保留一个URL作为HTTP,其余所有URL都是https。 我的货币000-default.conf配置为: <VirtualHost *:80> RewriteEngine On RewriteCond %{HTTPS} off Redirect permanent / **https**://www.abc.com/ </VirtualHost> 重新启动发动机 重写条件%{HTTPS}关闭 重定向永久/**https**://www

我需要保留一个URL作为HTTP,其余所有URL都是https。 我的货币000-default.conf配置为:

<VirtualHost *:80>
    RewriteEngine On
    RewriteCond %{HTTPS} off
    Redirect permanent / **https**://www.abc.com/
</VirtualHost>

重新启动发动机
重写条件%{HTTPS}关闭
重定向永久/**https**://www.abc.com/
这会将所有URL重定向到https。 现在我在这个网站上有了一个URL,网址是http://www.abc.com/blog
我不希望它被重定向到https。我怎样才能做到这一点呢?

你目前的食谱有点混乱。RewriteCond不会阻止它后面的重定向,它只影响RewriteRule。但在端口80 vhost上,您永远不会看到HTTPS请求

您可以将重定向切换为实际使用mod_rewrite并添加异常。默认情况下,条件为和:

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !=www.example.com
RewriteCond %{REQUEST_URI} !^/blog$
RewriteRule ^(/.*) https://www.example.com/$1 [R=301]

使用example.com代替您的URL——答案显然不能包含该URL,但问题可以!