.htaccess同时更改文件扩展名并强制转换为https
我想用.htaccess将我的url从.php更改为.html 另外,我需要这个页面强制变成https 以上要求适用于特定页面而非整页.htaccess同时更改文件扩展名并强制转换为https,.htaccess,https,file-extension,.htaccess,Https,File Extension,我想用.htaccess将我的url从.php更改为.html 另外,我需要这个页面强制变成https 以上要求适用于特定页面而非整页 eg. http://domain/filename/XXX.php => https://domain/filename/XXX.html 有人知道如何解决这个问题吗?谢谢只需结合一些https规则和扩展修改 # Prevent endless loop RewriteCond %{ENV:REDIRECT_STATUS} ^$ # and redir
eg. http://domain/filename/XXX.php => https://domain/filename/XXX.html
有人知道如何解决这个问题吗?谢谢只需结合一些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]
只需结合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]