Mod rewrite to https for 2 pages only.

Heed to redirect all visits to http://www.mysite.com/register or http://mysite.com/register to https.
Also for http://www.mysite.com/login and http://mysite.com/login

How to do that in .htaccess rewrite rule?
LVL 26
Eddie ShipmanAll-around developerAsked:
Who is Participating?
 
ravenplCommented:
RewriteEngine on
#if the request matches /register* or /login*
RewriteCond %{REQUEST_URI} ^/(register|login)
#and https is not enabled
RewriteCond %{HTTPS} !=on
#redirect to https://server.name.from.configuration/whatever/user/requested
RewriteRule (.*) https://%{SERVER_NAME}/$1 [L,R]
0
 
ravenplCommented:
Something like

RewriteCond %{REQUEST_URI} ^/(register|login)
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://%{SERVER_NAME}/$1 [L,R]

Do You also need to get back to http:// if the URL is different to /login or /register ?
0
 
Eddie ShipmanAll-around developerAuthor Commented:
Not really.
0
 
Eddie ShipmanAll-around developerAuthor Commented:
can you explain the conditions?
0
 
Eddie ShipmanAll-around developerAuthor Commented:
perfect, tanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.