.htaccess redirect to subfolder, non-www to www and https -
so i'm having website stored inside public_html/www/. other domains stored in -for example- public_html/test/. in public_html have .htaccess file lot of redirects in it, apply website inside /www/ folder. inside /www/ folder have .htaccess (i don't know why, colleague did , left me without information). since have no idea how .htaccess works, have no idea , in file.
what need redirect domain.nl https://www.domain.nl (some folders should excluded, can see in code below - emailtemplates, paymentupdate, autocode, nieuwsbrieven, etc.) domain.nl stored inside public_html/www/ folder, needs redirect subfolder (which should not visible in web browser).
at moment, in root .htaccess file following:
# use https rewritecond %{http_host} ^(www\.)?domain\.nl [nc] rewritecond %{https} off rewritecond %{request_uri} !^/emailtemplates rewritecond %{request_uri} !^/paymentupdate_ideal rewritecond %{request_uri} !^/autocode rewritecond %{request_uri} !^/nieuwsbrieven rewritecond %{request_uri} !^/bevestig-aanmelding-nieuwsbrief rewritecond %{request_uri} !^/bevestig-afspraak rewritecond %{request_uri} !^/images/personal rewritecond %{request_uri} !^/uploadify rewriterule (.*) https://%{http_host}%{request_uri} [r=301,l] # link subfolder # rewriteengine on rewritecond %{http_host} ^(www.)?www.domain.nl$ rewritecond %{request_uri} !^/www/ rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ /www/$1 rewritecond %{http_host} ^(www.)?www.domain.nl$ rewriterule ^(/)?$ www/index.php?page=home [l] # non-www www #activate rewrite engine #rewriteengine on rewritecond %{http_host} ^(www.)?domain.nl rewritecond %{http_host} !^www\. rewriterule ^(.*)$ https://%{http_host}/$1 [r=301,l]
probably half of code isn't necessary, have absolutely no clue. other .htaccess file, within subfolder /www/, has following text don't understand (it contains more, nothing relevant):
rewritecond %{request_filename} !-f rewritecond %{request_uri} !(.*)/$ rewriterule ^(.*)$ http://www.domain.nl/$1/ [l,r=301]
i'm sorry if sound stupid. i've tried many things copied internet, unfortunately has concequences, results in other problems our website (links don't work anymore, such as). think reason doesn't work time, because it's stored in subfolder , don't know how combine lines in 1 work.
can me explain how fix , going wrong @ moment? because website not redirecting www. it's redirecting https gives me security error @ moment (because ssl stored on www.). super in advance!
my problem wrong order of checks. first, redirected https://, when did not use www., did not redirect https://www or redirected https://www.www. fixed problem re-ordering rules, below:
# non-www www rewritecond %{http_host} !^www\. rewriterule ^(.*)$ https://www.%{http_host}/$1 [r=301,l] # permanent redirect https:// rewritecond %{https} off rewritecond %{request_uri} !^/excluded_folder1/ rewritecond %{request_uri} !^/excluded_folder2/ rewritecond %{request_uri} !^/excluded_folder3/ rewriterule (.*) https://%{http_host}%{request_uri} [r=301,l] # use subfolder domain rewritecond %{http_host} ^(www.)?www.domain.nl$ rewritecond %{request_uri} !^/www/ rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ /www/$1 rewritecond %{http_host} ^(www.)?www.domain.nl$ rewriterule ^(/)?$ www/index.php?page=home [l]
Comments
Post a Comment