Forum Moderators: phranque
Any help would be much appreciated.
Cheers
Welcome to WebmasterWorld!
Code like the following, placed in httpd.conf, might do what you want. I have to warn you though, that working with SSL can be difficult. You will likely need to modify this code (or your planned implementation), unless I understood exactly what you are wanting to do.
Our purpose in this forum is not to write code on demand, but rather to help you learn to write your own code. For this reason, you'll need to study the following code, along with the documentation cited in our Forum Charter [webmasterworld.com], and understand how it works. We can then address your very specific questions in this forum.
RewriteEngine On
# If query_string contains "name=secure"
RewriteCond %{QUERY_STRING} name=secure
# And we're not already on port 443 (secure connection port)
RewriteCond %{SERVER_PORT} [code]!^443$
# Redirect to https for secure connection
RewriteRule ^/mod\.php$ https://www.mysite.com/mod.php [R=301,L]
Jim
many thanks for your Welcome and reply - I have been doing a large amount of research since my post and have got to the point now where I am stuck.
The code below is where I have got tooo. Unfortunately it does not seem to work 100% as the second set of code seems to be executed even tho is does not match the condition - any pointers?
RewriteCond %{REQUEST_URI} ^/TEST/secure.html$
RewriteCond %{SERVER_PORT}!^443
RewriteRule ^(.*)$ [mydomain.com...] [R,L]
RewriteCond %{REQUEST_URI}!^/TEST/secure.html$
RewriteCond %{SERVER_PORT} ^443
RewriteRule ^(.*)$ [mydomain.com...] [R,L]
Many Thanks.
[edited by: doodlebug at 6:23 pm (utc) on July 8, 2005]
A useful trick you can use for debugging is to append your variables to the substitution URL as a query string:
RewriteRule ^(.*)$ http://www.example.com/TEST/$1?port=%{SERVER_PORT}&URI=%{REQUEST_URI} [QSA,R,L]
Then if soemthing goes wrong, you can examine the variables to be sure they are what you expected.
Jim
A little further forward but still pulling my hair out - hehe.
RewriteCond %{REQUEST_URI} ^/TEST/secure.html$ [OR]
RewriteCond %{QUERY_STRING} ^(.*)name=Secure(.*)$
RewriteCond %{SERVER_PORT}!^443
RewriteRule ^(.*)$ [mydomain.com...] [R,L]
RewriteCond %{REQUEST_URI}!^/TEST/secure.html$
RewriteCond %{QUERY_STRING}!^(.*)name=Secure(.*)$
RewriteCond %{SERVER_PORT} ^443
RewriteRule ^(.*)$ [mydomain.com...] [R,L]
If I comment out the last 4 lines it works perfectly, if I leave them in SLL kicks in but all the images are red crosses - any idea/pointer why the latter conditions mat effect the first four?
Yours now bald! - lol.
If I comment out those last 4 lines from the above the SSL redirect works fine.
Thx again for your time.