user1892989
user1892989

Reputation:

https and http combined .htaccess (different issue)

OK. Hopefully someone can help me with a suggestion-

  1. I have a WordPress multisite using subfolders
  2. I am using WooCommerce
  3. I have a std Ubuntu 12.04/LAMP server with a GoDaddy Certificate installed

If it turn on SSL, it affects my entire domain (obviously) so my primary site ends up as: 'https://main-sitename.com'

My multisite blogs also come up as: https://main-sitename.com/blogname-1 https://main-sitename.com/blogname-2

and so on. ALL of my menu links are also https which disables outside links because the urls all get prepended with https. :-/

What I am trying to do is get this:

http://main-sitename.com http://main-sitename.com/blogname-1 http://main-sitename.com/blogname-2

https://main-sitename.com/shop/ (WooCommerce will force HTTPS on checkout and then un-enforce it when done).

Upvotes: 1

Views: 1076

Answers (1)

Erik Nedwidek
Erik Nedwidek

Reputation: 6184

It sounds like SSLRequireSSL has been set for the entire server. Since you only want to enforce HTTPS on /shop/ directory. Add a .htaccess file in that directory that contains:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

This will force anyone connecting to your shop with http:// to be redirected to the same URI, but on https://

EDIT 2

This works for me (with www.myserver.com changed to my real server name). I'm using date and name permalinks in WP. As soon as I go to http://www.myserver.com/shop/ I'm redirected to https. It preserves the URI.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
# Addition to force redirect to https when they visit the shop!
RewriteBase /
RewriteCond %{HTTPS} !on
RewriteRule (shop/.*$) https://www.myserver.com/$1 [R=301,L]
# Back to WordPress changes
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Upvotes: 0

Related Questions