views:

454

answers:

2

Hi,

Sorry if this has been asked before, but I couldn't find it. I have a folder which when I visit loads in both HTTPS and HTTP.

I want all the files in that folder to load in HTTP except for one file. The file I need in in HTTPS is: login.php and this folder is called "forum". Also if it helps: All the files in the folder are *.php.

I was trying something along the lines of:

#RewriteCond %{SERVER_PORT} !^443$
#RewriteRule ^/login.php$ - [L]

#RewriteCond %{SERVER_PORT} ^443$
#RewriteRule ^(/login.php) $ https://%{HTTP_HOST}/$1 [QSA,NC,R,L]

#RewriteCond %{SERVER_PORT} !^443$
#RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [QSA,NC,R,L]

I'm a bit of an amateur when it comes to mod_rewrite so forgive me if the above is completely off. Also if you post a solution I would appreciate it if you post it with an explanation so I can actually LEARN how it works.

Thanks in advance! David

+1  A: 

Give this a try:

 Options +FollowSymLinks
 RewriteEngine On


 # port 443 traffic to http://, except login.php
 RewriteCond %{SERVER_PORT} ^443$
 RewriteCond %{REQUEST_URI} !^/login\.php$ [NC]
 RewriteRule .* http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

 # port 80 traffic for login.php to https://
 RewriteCond %{SERVER_PORT} ^80$
 RewriteCond %{REQUEST_URI} ^/login\.php$ [NC]
 RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
Sean A.O. Harney
I'm performing a migration at the moment, so will try this as soon as I've finished. Thanks!
Something seems to be happening, but it doesn't exactly work.Now the forum still loads under HTTPS, meaning the index.php does, but as soon as I click on a forum link I get an ERROR, that it doesn't "exist".It loads fine if I go in HTTP.It might have something to do with the SEO Mod I have installed? Nonetheless the SEO rules are underneath these ones. So they should be read first right?If you want to have a look for yourself to see what's happening: http(s)://www.redbid.com/forum/.Cheers
am not 100% sure my answer is correct I'm afaid. I have no idea about SEO Mod. I thought the rewrite rules I gave should redirect https traffic for any page but the /login.php to http. I might be able to help if you could post the server error logs.
Sean A.O. Harney
Yes I see that now, it lets me navigate into the forums but once I click to open the forum I get the 404 not found. It looks like the forum script you are using is creating descriptive URLs probably using some sort of rewriting rules itself that might be conflicting. Is SEO Mod a dependency of the forum script?
Sean A.O. Harney
I've disabled the SEO Mod and commented the SEO rewrite rules in the config. None the less the site is still loading in HTTPS.However this time there is no 404 Error this time.Any thougthts?Note: I've disabled all the other mod_rewrite rules in the config, to test this case and make sure nothing is conflicting.Cheers!
A: 

Try these rules:

RewriteCond %{SERVER_PORT} !=443
RewriteRule ^login\.php$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{SERVER_PORT} !=80
RewriteRule !^login\.php$ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Gumbo
Hi Gumbo, thanks for your input. However the same issue as occurs as in the solution mentioned above. Both with and without the SEO Mod enabled.Any other thoughts?Cheers
Did you put these rule before or after your other rules? If not before, do it.
Gumbo