重写特定规则(html url到php,使用https)


Rewrite specific rule (html url to php, with https)

我继承了一个项目,该项目有一个巨大的htaccess文件,从".html"url到php文件进行了大量重写,如下所示:

RewriteRule ^login'.html$ login.php

我知道这个网站上有很多类似的问题,但在我的情况下,这些问题都不起作用,大多数只是http->https重写/重定向。

我只想用以下行为仅更改特定规则:

1http://www.example.com/login.html-->应转到-->https://www.example.com/login.html

2https://www.example.com/login.html-->应该映射到login.php文件(就像上面重写的一样)。

首选htaccess解决方案,但任何其他解决方案也将不胜感激。

RewriteCond %{HTTPS} off
RewriteRule ^login'.html$ https://www.example.com/login.html [R,L]
RewriteCond %{HTTPS} on
RewriteRule ^login'.html$ login.php

此外,请在您的in.conf文件中检查DocumentRoot对于*:80:443 VirtualHosts是相同的,并且两者都具有AllowOverride All

(通常情况下,只有当您没有访问主服务器配置文件的权限时,才应该使用.htaccess文件。)