现在,如果有人使用https://mysite.com,我会重新定向100%的时间
<VirtualHost *:443> ServerAdmin [email protected] ServerName mysite.com ServerAlias www.mysite.com RewriteEngine on RewriteRule (.*) http://%{HTTP_HOST} [L,R=permanent] <VirtualHost>
不过,现在我想有条件地redirect。 如果用户转到https://mysite.com/abc/ ,那么我想使用https; 否则redirect。
我该怎么做呢? 我试着阅读文档,但是找不到我需要的东西。
我在Ubuntu Linux上使用Apache。
尝试在RewriteRule之前添加一个RewriteCond (重写条件)。 我会尝试写这样的事情:
RewriteCond%{REQUEST_URI}!^。*(abc)。* $ [NC]
这是一些额外的阅读,如果这没有帮助:
– http://www.whoopis.com/howtos/apache-rewrite.html
– http://www.sitepoint.com/article/apache-mod_rewrite-examples/
我会重现我在Slicehost论坛上给你的答案:
RewriteRule !^/abc/ http://%{HTTP_HOST} [L,R=permanent]
(编辑)的
有一些Apache的例子: https : //httpd.apache.org/docs/trunk/rewrite/remapping.html#canonicalhost
你也可以用下面的指令完成这个工作:(2.4及更高版本)
redirect“ /”“http://www.example.com/ ”或者,例如,要将您网站的一部分redirect到HTTPS,您可以执行以下操作:
redirect“/ admin /”“https://www.example.com/admin/ ”