Force a Directory to load in HTTPS SSL

Use the following .htaccess code to force a particular directory to load in HTTPS/SSL mode.

# Force SSL over mydirectory
RewriteEngine On
# file.php will not be forced over SSL - Uncomment the line below if needed
#RewriteCond %{REQUEST_URI} !^/mydirectory/file.php [NC]
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^mydirectory(/.*)?$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

Was this answer helpful?

Also Read

GET/POST Security with .htaccess

Below is a useful code to block out some common exploits for GET/POST values with .htaccessSimply...

Block Bad Bots and Spiders using .htaccess

Below is a useful code block for blocking a lot of the known bad bots and site rippers currently...

Disabling Magic Quotes GPC

How to turn off magic quotes gpc (required by Joomla 3 and some other scripts).1. Create a...

Speed up WordPress Leveraging Browser Caching via .htaccess

Insert the following code to your .htaccess file to increase the speed of your WordPress website...

Point your home page URL to a subdirectory

Method 1 - Redirect your main domain to a subfolder on that domain: RewriteEngine On# Change...