Problem redirecting HTTP to HTTPS and back again

Hi guys, I’ve done a lot of searching and found some very helpful threads.

I want to redirect a directory on my site, /contact-us and all sub-directories to HTTPS.

Any other pages I want to use HTTP.

I found this thread: and use dklynn’s example:

RewriteEngine on

# redirect DIRECTORY requiring a secure server

RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^checkout{REQUEST_URI} [R=301,L]

# redirect pages not requiring a secure server

RewriteEngine on
RewriteCond %{SERVER_PORT} ^443$
RewriteRule !^checkout{REQUEST_URI} [R=301,L]

but this doesn’t seem to work for me. If I remove the HTTPS to HTTP part it works fine, but with both blocks in my .htaccess file, any attempt to access a file in /contact-us redirects to the homepage.

I’m not too familiar with this sort of tinkering and I don’t know if this is affected by the Wordpress .htaccess rules below:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

Please help!


I’m ready to crash tonight (er, well into this morning) so let me just refer you to the secure server sample code sections of the mod_rewrite tutorial linked in my signature. All the information you need is there!