Link to home
Start Free TrialLog in
Avatar of tektools
tektools

asked on

Redirect to https to http confusion

currently we are moving our website to an apache front end, running PHP on it.  The main part of the website is running jsp so Tomcat is serving the pages.  I have everything all working and communicating together.  the site is up and running the way it should.  there is a portion of our website that uses an SSL connection, I can get everything to display, however when I select the link to go to my https part of my website, it doesnt redirect to https.  if I type in the https portion the page comes up.  I am not sure if I need to have an .htaccess file or use mod_rewrite.  Since this is the only page that needs to be redirected I wanted to make sure..  How do I redirect from http to https?

thanks
Avatar of Steve Bink
Steve Bink
Flag of United States of America image

I use a similar strategy, but mine is site-wide.  I don't want to refuse connections on port 80...I want them to be redirected to SSL instead.  My current rules:

#forward every host besides webmail
RewriteCond %{HTTP_HOST}        !^webmail\.mydomain\.com [NC]
RewriteRule ^(.*)         https://www.mydomain.com$1 [L,R]

You could easily change the rule to isolate certain directories, or specific files:

RewriteRule ^/dir/file.txt https://www.mydomain.com/dir/file.txt [NC,L]
Avatar of tektools
tektools

ASKER

Is that in my htaccess file or is that something I put in my httpd.conf file in apache?
My configuration has that in an include file, which holds the VirtualHost container for that domain.  They could go in an .htaccess file, though you should know that some directives for mod_rewrite need to be in the conf file.

You can learn more about mod_rewrite here:

http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
> however when I select the link to go to my https part of my website, it doesnt redirect to https.  if I type in the https portion the page comes up.
So I guess the link is not https at all!

Please tell us what pages should be redirected to https, then we'll ship You with set of rewriteRules
the folder/pages that would need to be redirected to https would be

http://www.mysite.com/resellers/*

everything in that folder would need to be redirected to https://www.mysite.com/resellers/
ASKER CERTIFIED SOLUTION
Avatar of ravenpl
ravenpl
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks ravenpl.  I have another question for mounting an network linux share for my company's download directory to our webserver. I should be posting in the next day or so, now I have to focus on testing.

thanks again