Jump to content

mod_rewrite rule


mummana

Recommended Posts

Hi,

I want to redirect from HTTP to HTTPS login page .

 

It works correclty, when I request with http://test.com, it redirects http://test.com/home/login.jsp

 

RewriteCond %{HTTP_HOST} test.com [NC]

RewriteCond %{HTTPS} !on

RewriteRule .* test.com/home/login.jsp [R=301]

 

But when I request with https://test.com, it is not redirecting to the home page.

 

Could you please help me regarding.

 

Thanks

Srini

Link to comment
https://forums.phpfreaks.com/topic/137489-mod_rewrite-rule/
Share on other sites

Hi Srini

 

The rewrite rule you've given won't work for https because the second line checks that it is not encrypted.

 

in pseudo-code, you've got:

if the requested host contains "test.com" ignoring case
AND it is not an encrypted connection
then re-write to the login page with a permanent redirect 

 

I'm having problems of my own along these lines, so I'm not really in a position to give you the answer. I do have a couple of suggestions/questions, though.

 

1. you'll need to re-write to https to make it use the encrypted connection.current encryption

RewriteCond %{HTTP_HOST} test.com [NC]
RewriteRule .* https://test.com/home/login.jsp [R=301] 

 

2. As it stands, this rule will surely re-write for any and all requests that come to test.com domain - graphics, html, flash, everything will get redirected to the login. Once you've logged in, any other page will be re-directed to the login script.

 

Sorry for not having a definitive answer.

Kevin

Link to comment
https://forums.phpfreaks.com/topic/137489-mod_rewrite-rule/#findComment-718576
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.