[Domain Mapping] Domain Mapping and htaccess

Hi guys i tried to find a solution for my multisite. All that i want is that all mapped domains are going to https://www.examplemappedomain.de at the moment i have the following problem: when i called the domain without https and only with www. nothing will happen only examplemappedomain.de calling in the browser will bring me an redirect to https://www.examplemappedomain.de

So what i need is a propper solution in the htaccess to get the result https://www.examplemappedomain.de for calling www. examplemappeddomain.de and examplemappedomain. and this for all the multisite domains:
https://www.examplemappedomain1.de
https://www.examplemappedomain2.de
....

at the moment i used this code:
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^examplemappedomain1\.de [NC]
RewriteRule ^(.*)$ https://www.examplemappedomain1.de/$1 [R=301,L]

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^examplemappedomain2\.de [NC]
RewriteRule ^(.*)$ https://www.examplemappedomain2.de/$1 [R=301,L]

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^examplemappedomain3\.de [NC]
RewriteRule ^(.*)$ https://www.examplemappedomain3..de/$1 [R=301,L]

RewriteEngine On
Rewritecond %{HTTP_HOST} !^www\.maindomain\.de [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

i granted you access to the site, let me know if you need an ftp access i will send you the accocunt details.

  • hannes
    • Site Builder, Child of Zeus

    when i put it directly under "RewriteEngine on" it works very well but all sites of my multisite will drop to https://www.examplemappedomain1.de/$1 also the main site and all the sites with no certificate will als get an https in front of it. when i put it down the other redirects it will not effect! To understand my problem better: I have a multisite with many site, some have an ssl certificate for their mapped domains and some not, so i need a solution for both.

    Or do i have to define all sites that it will work, when it is so, can you please give me an example how it should look for the main site, a site with https and a site with no https

    To bring non-www Adresses i used the domain mapping plugin and made the www-version to the primary domain.

    Also have alook at my htaccess:

    RewriteEngine On
    
    RewriteBase /
    
    RewriteRule ^index\.php$ - [L]
    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]
    
    RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} !^www\.examplemappeddomain1\.de [NC]
    RewriteRule ^(.*)$ https://www.examplemappeddomain1.de/$1 [L,R=301]
    
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule (.*) https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
  • hannes
    • Site Builder, Child of Zeus

    I had cleaned everything in the htaccess only this is in:

    RewriteEngine On
    
    RewriteBase /
    
    RewriteRule ^index\.php$ - [L]
    # add a trailing slash to /wp-admin
    RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]

    the mapped domains in the domain mapping tool are with https. I always mapped 2 domains =>
    https://www.exampledomain.de and
    https://exampledomain.de and marked the first with www as primary domain.

    now typing exampledomain.de in the brwoser will redirect to: https://www.exampledomain.de
    thats cool, but ....
    typing http://www.exampledomain.de direct in the brwoser (forget the http:// in front i can not delete it here in the mask) will not redirect to https://www.exampledomain.de nothing happens than!

    when i use your code: `RewriteCond %{HTTPS} off [OR]
    RewriteCond %{HTTP_HOST} !^www\.examplemappedomain1\.de [NC]
    RewriteRule ^(.*)$ https://www.examplemappedomain1.de/$1 [L,R=301]`

    all other mapped domains will redirect to this domain. So my quastion was how to setup the htacess right for the main domain, the domains with ssl and the domains without ssl

    thanks for help

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.