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 URL Masking Examples

If you would like to access a specific URL for your domain but do not display it in the browser's...

Redirect non-www to www over http and https

Use the following .htaccess code to redirect non-www URLs to www over http and https. Create, or...

How to execute php code as .htm or .html files

In your .htaccess file insert this line of code. addhandler application/x-httpd-php .htm .html

GET/POST Security with .htaccess

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

Resolving XMLRPC DDoS WordPress Attack with .htaccess

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