php - Force HTTPS Redirect on URL and Subfolders, as well as Remove WWW and .HTML -


i'm using following .htaccess configuration enforce https protocol, , remove www prefix.

rewriteengine on rewritecond %{https} off rewritecond %{http_host} ^www\.(.*)$ [nc] rewriterule ^(.*)$ https://%{http_host}%{request_uri} [l,r=301] 

however, doesn't function subfolders, e.g. www.abc.com/projectdirectory/index.html

is there way enforce rule across entire website structure? so, if user manually types url field: www.abc.com/projectdirectory/index.html or www.abc.com/projectdirectory/projectx/index.html, adds https protocol url , removes www.

in addition, there way remove .html? i've used snippet before, , affected recognition of .js, .php files.

rewritecond %{request_uri} !\.[a-za-z0-9]{3,4} rewritecond %{request_uri} !/$ rewriterule ^(.*)$ $1.html 

to remove .html extension need .htaccess rule this:

rewriterule ^([^\.]+)$ $1.html [nc,l] 

use above mentioned rule instead of 1 have posted here.

you add rewritebase / after rewriteengine on .htaccess this:

rewriteengine on rewritebase / rewritecond %{https} off rewritecond %{http_host} ^www\.(.*)$ [nc] rewriterule ^(.*)$ https://%{http_host}%{request_uri} [l,r=301] 

Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -