Solved

How to use htaccess to force https on the homepage only

Posted on 2008-10-27
1
428 Views
Last Modified: 2008-10-28
I want to force https:// on the index page only of a site.
Right now, I am using htaccess to append www to the url:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.mysite.com$
RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301]

How do I force ssl to only the index page? There is a login box on this page and I need it to be secure, but the rest of the pages, I dont want to force ssl (I will control the rest through navigation).
0
Comment
Question by:lexo
1 Comment
 
LVL 43

Accepted Solution

by:
ravenpl earned 500 total points
ID: 22819602
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.mysite.com$
RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]

RewriteCond %{HTTPS} !=on
RewriteCond %{REQUEST_URI} ^(/|/index.php|/index.html)$
RewriteRule .* https://www.mysite.com%{REQUEST_URI} [L,R=301]
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
wget saving web page help 4 78
Server specifications for web hosting 7 90
Apache / XAMPP  authorisation 10 44
WordPress website error - Unable to access website. 5 28
Introduction As you’re probably aware the HTTP protocol offers basic / weak authentication, which in combination with the relevant configuration on your web server, provides the ability to password protect all or part of your host.  If you were not…
If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

5 Experts available now in Live!

Get 1:1 Help Now