Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have SSL configured for a cart directory in my website. I'm having a very difficult time trying to configure SSL for a different directory within the same website. I ask the question on SO, and was hoping it would eventually get migrated here for more help (I don't want to make the same post twice).

Anyway, after awhile I noticed the directory I need SSL on, /admin, is actually accepting both http and https, so now to make my life easier and get this out of the way.. I'm just trying to configure a URL Rewrite for


to rewrite to


This is what I have tried, and it is not working:

RewriteEngine on
RewriteRule ^https://www.shop.com/admin/index.php$ http://www.shop.com/admin/index.php

How can rewrite the default page for this directory to use https? I know this is probably sloppy, but I don't know what else to do. If you could help me set up ssl legitly for this directory, that would be even better.

ps - The url rewrite docs are complicated!

share|improve this question
up vote 2 down vote accepted

Try this:

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} admin
RewriteRule ^(.*)$ https://www.shop.com/admin/$1 [R,L]

You may need to replace the $1 with just index.php instead.

share|improve this answer
Sweet!! It worked, thank you so much. Would mind telling me what [R,L] does? – Nick Rolando May 31 '12 at 1:03
Yes sure: the R means "redirect" where you could specify R=301 (assumed) or R=302 which has to be done manually. The L if I remember correctly, is for "Symbolic Link" but I could be wrong. I just know they work, so don't remove them. – ionFish May 31 '12 at 1:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.