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

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

Laravel mail error `Swift_TransportException in StreamBuffer.php line 269: Connection could not be established with host smtp.gmail.com [ #0]` -

c# SetCompatibleTextRenderingDefault must be called before the first -