1

I found a potential solution to this question already here: Force HTTPS on certain URLs and force HTTP for all others but this did not redirect users as expected.

I am trying to get everyone who loads any file within http://mydomain.com/registration/ or its subdirectories to be directed to https://mydomain.com/registration/ (with or without www., I don't care) but for all files not within that directory to be forced to use HTTP.

Adapting the solution above by simply replacing 'my' with 'registration' saw no change for non-/registration/ URLs and for any /registration/ URLs the user ended up in a redirect loop.

I think it may have something to do with what is already in my .htaccess file. I need the new code and my existing code to work concurrently and that's where I really need help:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^runners/([a-z0-9\-]+)/([a-z0-9\-]+)/([a-z0-9\-]+)/([a-z0-9\-]+)$ index.php?p=runners&sortby=$1&dir=$2&page=$3&perpage=$4 [L]
RewriteRule ^([a-z0-9\-]+)$ index.php?p=$1 [L]
</IfModule>
Community
  • 1
  • 1
Alan
  • 39
  • 3
  • Please do not force people to use unencrypted connections if you support SSL. – ThiefMaster Apr 19 '14 at 20:07
  • ThiefMaster, I appreciate what you're saying but there will come a time when my site remains live but no longer has an SSL certificate because the /registrations/ subdirectory will be taken offline and the rest of the site will be left online. SSL certificates are expensive so while I don't need it I will keep the rest of the site accessible via HTTP but I don't want people with old links to https:// pages to be presented with certificate errors when they visit my site! – Alan Apr 19 '14 at 20:25
  • Are they? Check startssl.com (not affiliated with the, just a user). You get properly trusted certificates for free. – ThiefMaster Apr 19 '14 at 21:24

1 Answers1

-1

Try this:

RewriteCond %{HTTPS} =off
RewriteCond %{REQUEST_URI} ^/registration [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R,QSA,L]

This should be pasted right below RewriteBase / line.

Rahil Wazir
  • 10,007
  • 11
  • 42
  • 64