user2753222
user2753222

Reputation: 1

forced https on subdomain .htaccess file is sending wordpress admin page to parent domain

Ok. I'm desperate.

Basically when i add the #Force https lines below it's then sending my shop.mydomain.com/wp-admin to mydomain.com/wp-admin Aaaaaah.

My wordpress shop site lives inside the main domain folder (inside the other wordpress site) i.e. public_html/mydomain(wordpress install)/shop(wordpress install)

I have a Wildcard SSL installed on the www.mydomain.com (which handles 1st level subdomains). The SSL part seems to be working fine.

Here is the .htaccess inside the folder /shop:

#Send www to https
RewriteEngine On 
RewriteCond %{HTTP_HOST} ^www.shop.mydomain.com$ [NC]
RewriteRule ^(.*)$ https://shop.mydomain.com/$1 [R=301,L]

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

# BEGIN WordPress
etc etc
# END WordPress

And inside the main domain folder public_html/mydomain:

#.htaccess WildCard SSL
RewriteEngine On
RewriteCond %{HTTP_HOST} ^shop.mydomain.com$
RewriteCond %{REQUEST_URI} !^/shop/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /shop/$1
RewriteCond %{HTTP_HOST} ^shop.mydomain.com$
RewriteRule ^(/)?$ shop/index.php [L]

# BEGIN WordPress
etc etc
# END WordPress

Would be grateful for any advice. =>

Upvotes: 0

Views: 707

Answers (1)

Grin N. Berrett
Grin N. Berrett

Reputation: 11

Place the following in the .htaccess for the domain

    # .htaccess WildCard SSL + wordpress + subdomain
RewriteEngine on
RewriteCond %{HTTP_HOST} ^shop.domain.com$
RewriteCond %{REQUEST_URI} !^/shop/
RewriteRule ^(.*)$ /shop/$1
RewriteCond %{HTTP_HOST} ^shop.domain.com$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(/)?$ shop/index.php [L]

# BEGIN WordPress for main domain
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteRule ^index\.php$ - [L]
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Upvotes: 1

Related Questions