I want to be able to have the an URL be reformed in an htaccess file and redirect a file that is no longer present.
Taking this:
http://www.example.com/foo/thing.htm
and having this be renamed to:
I've used the following code
RewriteEngine On
Redirect 301 /foo/thing.htm /foo/
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI}
The problem I have had is that when the Redirect 301 happens, the RewriteCond is skipped according to https://htaccess.madewithlove.com/
Redirect 301 /foo/thing.htm /foo/
The new url is http://www.example.com/foo/
Test are stopped, a redirect will be made with status code 301
and the output is http://www.example.com/foo/
How can I get all of my commands in my htaccess file be ran so that the URL is processed properly in addition to any other additional commands such as cache control and webp compatability?
http://www.example.com/foo/
then redirect to HTTPS? It isn't usually a problem to have a short chain of redirects.