.htaccess同时更改文件扩展名和强制为https [英] .htaccess change file extention and force to https at the same time

查看:153
本文介绍了.htaccess同时更改文件扩展名和强制为https的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用.hp更改我的网址.htaccess
我也需要这个页面强制转换为https
以上要求适用于某个页面而不是整页...

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

推荐答案

只需合并一些https和扩展修改规则

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]

这篇关于.htaccess同时更改文件扩展名和强制为https的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆