问题
I want to change my url from .php to .html with .htaccess also, I need this page force becoming to https the above requirement are for the certain page not whole page...
eg. http://domain/filename/XXX.php => https://domain/filename/XXX.html
do anyone know how to solve this problem? thanks
回答1:
Just combine some rules for https and extension modification
# Prevent endless loop
RewriteCond %{ENV:REDIRECT_STATUS} ^$
# and redirect php to html
RewriteRule ^(.+)\.php$ https://%{HTTP_HOST}/$1.html [L]
# Enforce https
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L]
# Finally serve content
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)\.html /$1.php [L]
来源:https://stackoverflow.com/questions/37633958/htaccess-change-file-extention-and-force-to-https-at-the-same-time