I'm running a multisite wordpress installation with 13+ sites.
www.domain.com
www.domain.es
www.domain.it
and so on...
I must redirect the wp-admin folders for each domain to https://secure.domain.tld
Examples:
http://www.domain.com/wp-admin => https://secure.domain.com/wp-admin
http://www.domain.es/wp-admin => https://secure.domain.es/wp-admin
http://www.domain.it/wp-admin => https://secure.domain.it/wp-admin
Right now I'm using:
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.domain\.com
RewriteRule ^wp-admin https://secure.domain.com/wp-admin/ [R=301,L]
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.domain\.es
RewriteRule ^wp-admin https://secure.domain.es/wp-admin/ [R=301,L]
It works. But it sucks. Is there any clean solution to not repeat this for each domain? Is there any variable matching possibile with the host?
Thanks.
You can use regex alternation. So for your given example you can use:
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(?:www\.)?domain\.(com|es)$
RewriteRule ^wp-admin https://secure.domain.%1/wp-admin/ [R=301,L,NC]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.