apache - Redirect secured domain to secured subdomain using htaccess -


i have 3 domains , 1 hosting. trying use same hosting of 3 domains through htaccess. so, created subdomains name on domain linked hosting, looks below.

www.site1.com [main domain linked hosting]

site2.site1.com [subdomain www.site2.com]

site3.site1.com [subdomain www.site3.com]

what want achieve is, user shouldn't go subdomain site2.site1.com, instead able go www.site2.com , request sent site2.site1.com @ backend.

up here, done , worked well. problem comes afterwards, when adds ssl on site. have ssl of these domain , subdomain. if user visit non-ssl, should redirected ssl one. of ssl works when add ssl of them, start getting 500 error.

here .htaccess file

rewriteengine on directoryindex index.php  rewritecond %{https} off rewriterule ^(.*)$ https://%{http_host}%{request_uri} [l,r=301]  rewritecond %{http_host} ^site2.com rewriterule ^(.*) https://site2.site1.com/$1 [p] rewritecond %{http_host} ^www.site2.com rewriterule ^(.*) https://site2.site1.com/$1 [p]  rewritecond %{http_host} ^site3.com rewriterule ^(.*) https://site3.site1.com/$1 [p] rewritecond %{http_host} ^www.site3.com rewriterule ^(.*) https://site3.site1.com/$1 [p]  rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^ index.php [l] 

as add https on redirection link, start giving me 500 error whereas when make redirection http not load page because non-secured site http://site2.site1.com loaded on secured https://www.site2.com , in result, nothing shown.

here need resolve problem. have looked on different questions haven't found question relevant me because need keep .htaccess working redirection , ssl. moreover, need redirect www one, if not added in url.

any appreciated.

like, times experienced here have resolved problem myself. resolution problem following htaccess

rewriteengine on directoryindex index.php  rewritecond %{https} off rewriterule ^(.*)$ https://%{http_host}%{request_uri} [l,r=301]  rewritecond %{http_host} ^site2.com rewriterule ^(.*) site2/$1 rewritecond %{http_host} ^www.site2.com rewriterule ^(.*) site2/$1  rewritecond %{http_host} ^site3.com rewriterule ^(.*) site3/$1 rewritecond %{http_host} ^www.site3.com rewriterule ^(.*) site3/$1  rewritecond %{request_filename} !-d rewritecond %{request_filename} !-f rewriterule ^ index.php [l] 

in way instead of pointing url subdomain having https have reference directory instead because path same that, , when enter url https page opens , don't give error.


Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -