我想用.htaccess将我的网址从.php更改为.html 另外,我需要这个页面强制成为https 以上要求适用于特定页面而非整页...
eg. http://domain/filename/XXX.php => https://domain/filename/XXX.html
有谁知道如何解决这个问题?感谢
答案 0 :(得分:2)
只需合并https和扩展程序修改的一些规则
# 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]