php - Redirect all subdomains from HTTP to HTTPS using htaccess -
i have domain , working https example
http://example.com/
now creating sub domains demo1.example.com, demo2.example.com , on.
i need sub domains must redirect , access https.
i have write code in .htaccess see below redirecting main domain when access sub domains.
my htaccess code is
<ifmodule mod_rewrite.c> <ifmodule mod_negotiation.c> options -multiviews </ifmodule> rewriteengine on rewritecond %{https} off rewriterule ^(.*)$ https://%{http_host}%{request_uri} [l,r=301] # redirect trailing slashes if not folder... rewritecond %{request_filename} !-d rewriterule ^(.*)/$ /$1 [l,r=301] # handle front controller... rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^ index.php [l] </ifmodule>
edit
i have main website @ root , other sub-domains code @ 1 of folder. whenever sub-domain created point folder only.
rewriteengine on rewritecond %{server_port} 80 rewriterule ^(.*)$ https://yourdomain.com/$1 [r=301,l]
Comments
Post a Comment