Suppose you want to redirect one url from your website to some other page on the web on your won site. Then how would you do that? Well, it can be done in many different ways like using server side coding (e,g. PHP) or client side coding (e.g. Javascript) or best through coding the web serving software which in most cases is Apache. Apache is a software as you might know which servers the web page and HTTP requests made to your server. So you can configure apache and tell it to redirect a certain HTTP request to some other page. And this can be done by adding a simple line of code into the .htaccess file that sits in the root folder of your website. The code is as below:

The above code will redirect the request made to your website for the android-app page to the Goolge play store page displaying your app (the code 301 means permanent redirect). It’s that simple. However, if the user types in /Android-App or some other form of mixed up upper and lowercase letters then the above redirect will not work. And unlike rewrite rules we can’t use No Case (NC) flag with redirect to tell it to ignore cases. So what to do? Well, we can try to write redirect statements to match every possible case, which is of course absurd, or we can write URL rewrite conditions to do the redirection. However, even though URL rewriting can be used for redirection, its intended use is to format, organize and modify URLs to look prettier and convenient. So a better and simpler solution for doing the redirection is using the RedirectMatch directive which will redirect based upon the regular expression match of the given URL. So using RedirectMatch we can write the above redirection as below which will ignore the case of the request string:

Now the above statement will work for any combination of upper and lower cases in the string due to the presence of the regular expression of “?i”. However, one demerit of the above statement is that it will match to any URL request that has “/android-app” string in it.  For example, if you have an image on your website named android-app-icon.png, then when the browser will send request for it, Apache will redirect to the request to the google play page. So we can make the statement better as below:

The above code is just same except that it says “/android-app” string should be present at the last of the requested URL. Also the “(/)” regular expression says that a trailing slash can optionally be present at the end of the requested URL. Thus, if you need more customization to your URL redirect then RedirectMatch is the solution for you.