• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 260
  • Last Modified:

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?
0
Eddie Shipman
Asked:
Eddie Shipman
  • 3
  • 2
1 Solution
 
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
 
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
 
Eddie ShipmanAll-around developerAuthor Commented:
perfect, tanks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now