apache - redirect all subdomains from http to https -
i redirect http requests subdomain https using following code.
<virtualhost *:80> servername subdomain.example.com redirect 302 / https://subdomain.example.com </virtualhost>
now problem how do subdomains.
for example http:subdomain1.example.com should go https:subdomain1.example.com , http:subdomain2.example.com should go https:subdomain2.example.com
how do subdomains without having create 1 virtualhost of them
update
i found redirectmatch takes regular expression. know how using regex?
you this:
<virtualhost *:80> servername subdomain.example.com serveralias *.example.com rewriteengine on rewritecond %{http_host} ^(.+)\.example\.com$ rewriterule ^(.*)$ https://%1.example.com/$1 [r=302,l] </virtualhost>
the serveralias allow vhost act wildcard, can extract subdomain(s) host header , include them in rewrite https
Comments
Post a Comment