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>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s