I wish to redirect all HTTP and HTTPS requests to https://example.com/coming-soon.html.
Here is the last .htaccess file that I tried:
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php73” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php73 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}/coming-soon.html [L,R=302]
RewriteOptions inherit
Header set content-Security-Policy: upgrade-insecure-requests
I'm interested in always redirecting HTTP to HTTPS, that seem to work already, but in the meantime I need a redirection of entire domain to /coming-soon.html since the site is not ready yet. With the .htaccess above, HTTPS requests are not redirect to coming-soon.html.
Before, I had this other .htaccess file in place:
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php73” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php73 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteCond %{REMOTE_ADDR} !^123.45.67.89$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !coming-soon.html
RewriteRule ^(.*)$ /coming-soon.html [R=302,L]
RewriteOptions inherit
Header set content-Security-Policy: upgrade-insecure-requests
With this .htaccess, redirection is taking place and HTTPS works, but if i type https://example.com, it takes me to the root of the site file names in php.
I've read a lot of links but am literally either not understanding correctly or I'm doing something wrong. I'm aware of the RewriteCond for the IP it's not yet set for my IP as exception to the redirection. I can do without it the IP exception for time being.