sh4 sh4 - 1 year ago 133
Apache Configuration Question

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

I inherited a project with a huge htaccess file doing a lot of rewrites from ".html" urls to php files like this:

RewriteRule ^login\.html$ login.php

I know there a lot of similar questions around the site, but none of them worked in my case, most of them are just http -> https rewrites/redirections.

I just want to change only that specific rule with the following behaviour:

1.- --> should go to -->

2.- --> should map to login.php file (like in the rewrite above).

htaccess solution prefered, but any others would be appreciated also.

Answer Source
RewriteCond %{HTTPS} off
RewriteRule ^login\.html$ [R,L]

RewriteCond %{HTTPS} on
RewriteRule ^login\.html$ login.php

Also, check in your in .conf files, that DocumentRoot is the same for *:80 and :443 VirtualHosts, and that both have AllowOverride All

(In general, you should only use .htaccess files when you don't have access to the main server configuration file.)