开发者

htaccess SSL directory redirect and reverse

I have found similar questions, however no-matter what I try I am unable to get htaccess to do what I need it to. What I'd like is to direct visitors to an SSL connection when visiting one (or more) virtual subdirectories and then reverse this when they leave these selected subdirectories.

My rules look like this:

Options +FollowSymlinks
RewriteEngine on

#switch on SSL in /directory/ only
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} ^/directo开发者_运维知识库ry/
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

#switch off SSL in other folders
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^/directory/
RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R,L]

RewriteRule ^([^/\.]+)/?$ /index.php?var1=$1 [NC,L,QSA]
RewriteRule ^([^/\.]+)/([^/\.]+).html /index.php?var1=$1&var2=$2 [NC,L,QSA]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ /index.php?var1=$1&var2=$2 [NC,L,QSA]

It seems that switching on SSL and switching off SSL conflict and when I try to access any page via https://www.domain.com/foo/ I am correctly redirected to http://www.domain.com/foo/.

However, when trying to access http://www.domain.com/directory/ (which should be SSL) I am redirected to http://www.domain.com/index.php?var1=directory and not https://www.domain.com/directory/.

I would really really appreciate a bit of guidance over where I'm going wrong. I've trawled through stackoverflow and the web for hours and hours looking for an answer but I'm just going round in circles and can't see the wood from the trees.

Thank you for any guidance/help you can offer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜