Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess同时更改文件扩展名并强制转换为https_.htaccess_Https_File Extension - Fatal编程技术网

.htaccess同时更改文件扩展名并强制转换为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

我想用.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 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]