Change Root Folder Directory and Redirect to HTTPS with .htaccess -


i don't know .htaccess file , need assistance please. have few websites hosted 1 one cpanel account. didn't want have "main" site stored directly in public_html folder, moved subfolder , found .htaccess configuration allows me load main site subdirectory. working.

# .htaccess main domain subdirectory redirect  # not change line.  rewriteengine on  # change example.com main domain.  rewritecond %{http_host} ^(www.)?example.com$  # change 'subdirectory' directory use main domain.  rewritecond %{request_uri} !^/example_directory/  # don't change following 2 lines.  rewritecond %{request_filename} !-f  rewritecond %{request_filename} !-d  # change 'subdirectory' directory use main domain.  rewriterule ^(.*)$ /example.com/$1  # change example.com main domain again.  # change 'subdirectory' directory use main domain  # followed / main file site, index.php, index.html, etc.  rewritecond %{http_host} ^(www.)?example.com$  rewriterule ^(/)?$ example.com/index.html 

so said, above .htaccess allow me store site files in different folder rather right @ root. i'm trying force redirect site on https well. found site here:

force website use ssl

but, since don't understand .htaccess file i'm having trouble integrating these 2 features together. on appreciated. thanks.

i'm pretty figured out myself. had add end of .htaccess file:

rewritecond %{http_host} ^example\.com [nc] rewritecond %{https} off rewriterule ^(.*)$ https://%{http_host}%{request_uri} 

and works charm. full .htaccess file looks this, changes folder directory site use , forces on https.

rewriteengine on rewritecond %{http_host} ^(www.)?example.com$ rewritecond %{request_uri} !^/example_directory/  rewritecond %{request_filename} !-f  rewritecond %{request_filename} !-d rewriterule ^(.*)$ /example.com/$1 rewritecond %{http_host} ^(www.)?example.com$  rewriterule ^(/)?$ example.com/index.html rewritecond %{http_host} ^example\.com [nc] rewritecond %{https} off rewriterule ^(.*)$ https://%{http_host}%{request_uri} 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -