# How to force https: browsing on your app

**URL:** <https://www.ruby-forum.com/t/how-to-force-https-browsing-on-your-app/83286>\
**Category:** Rails\
**Created:** [January 24, 2007, 10:28pm UTC](https://www.ruby-forum.com/t/how-to-force-https-browsing-on-your-app/83286 "2007-01-24T22:28:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jh100000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b2d939/32.png) [@jh100000](https://www.ruby-forum.com/u/jh100000)\
**Post date:** [January 24, 2007, 10:28pm UTC](https://www.ruby-forum.com/t/how-to-force-https-browsing-on-your-app/83286/1 "2007-01-24T22:28:20Z")

</div>

hi,

i’ve got my app running on a dedicted linux box running lighttpd.

i have an ssl certificate installed and if i go to [https://mysite.com](https://mysite.com)  
then i get to view the site over a secure connection as expected.

however, if the user just enters [www.mysite.com](http://www.mysite.com) then the browser will  
use http: by default instead of https:.

does anyone know how to force connections to use https, or how to  
redirect urls with http: to their https: equivalent?

-john

---

<div class="post-metadata">

**Author:** ![jh100000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b2d939/32.png) [@jh100000](https://www.ruby-forum.com/u/jh100000)\
**Post date:** [January 25, 2007, 12:30am UTC](https://www.ruby-forum.com/t/how-to-force-https-browsing-on-your-app/83286/2 "2007-01-25T00:30:05Z")

</div>

> i’ve got my app running on a dedicted linux box running lighttpd.
> 
> i have an ssl certificate installed and if i go to [https://mysite.com](https://mysite.com)  
> then i get to view the site over a secure connection as expected.
> 
> however, if the user just enters [www.mysite.com](http://www.mysite.com) then the browser will  
> use http: by default instead of https:.
> 
> does anyone know how to force connections to use https, or how to  
> redirect urls with http: to their https: equivalent?

Somewhere within the ‘request’ object there’s got to be a protocol  
attribute. If that’s not “https” then redirect them. You could do this  
check as a before\_filter in application.rb to cover all your bases.

-philip

---

<div class="post-metadata">

**Author:** ![jh100000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b2d939/32.png) [@jh100000](https://www.ruby-forum.com/u/jh100000)\
**Post date:** [January 25, 2007, 2:36am UTC](https://www.ruby-forum.com/t/how-to-force-https-browsing-on-your-app/83286/3 "2007-01-25T02:36:21Z")

</div>

On 1/24/07, Philip H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > redirect urls with http: to their https: equivalent?
> 
> Somewhere within the ‘request’ object there’s got to be a protocol  
> attribute. If that’s not “https” then redirect them. You could do this  
> check as a before\_filter in application.rb to cover all your bases.
> 
> -philip
> 
> >

Philip,

The ssl\_requirement plugin by DHH is highly recommended for this type  
of thing. Very easy to use.

Repos:  
[http://dev.rubyonrails.org/browser/plugins/ssl\_requirement](http://dev.rubyonrails.org/browser/plugins/ssl_requirement)

Install:  
$./script/plugin install ssl\_requirement

–  
Zack C.  
[http://depixelate.com](http://depixelate.com)
