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

.htaccess 301 Redirect Generator

A simple .htaccess 301 redirect generator to be used to create SEO friendly permanent redirects....

.htaccess rules to Harden your website’s Security

Below you see a list of the important rules that you can add to your .htaccess file to harden...

Resolving XMLRPC DDoS WordPress Attack with .htaccess

Brute Force Attacks against WordPress have always been very common.Here is how to temporarily...

Point your home page URL to a subdirectory

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

GET/POST Security with .htaccess

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