Full Stack Software Developer

htaccess code for redirecting get request from index.php to index.html for temporary landing page

Sometimes for marketing purposes if you have a static landing page index.html and in the background there is another application running via index.php you can redirect all get request to the index.php to be redirected to the index.html using the following code. But if the request is not GET request or if the request has query parameters then it will not apply this rule and take user to the index.php instead.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteRule index\.php$ http://companydomain.com/index.html [R=301,L]
</IfModule>

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.