What is internal and external URL redirection?
Learn about the difference between internal redirection and external redirection in Apache speak.
We all have experienced URL redirection at one point or other in our tours of the web — when we typed in a URL without www and then got taken to its www version.
In this article, we'll take a look at two different kinds of URL redirection: internal redirection and external redirection.
Internal redirection
Internal redirection, sometimes also referred to as URL rewriting, is when one URL gets redirected to another one internally on the server without the user agent knowing of the change.
In technical terms, this type of redirection doesn't send a 301 or 302 HTTP response code to the browser and, thus, the browser doesn't know of any redirection happening on the back end.
Why do we need it?
Internal redirection is done usually to beautify URLs i.e make them look better and more readable for humans and search engines.
The following URL isn't at all readable or rememberable, is it? It is just some ugly combination of characaters!
http://example.com/product.php?id=90185&c=shoes&country=usCompared to it, the following URL is much more calm, beautiful and search engine friendly:
http://example.com/us/products/shoes/90185/green-football-shoesSo we could redirect this better URL internally to the first one which is the actual file for generating the HTML page. We don't want to show our users some ugly URLs in the address bar and thus employ internal URL redirection in our servers to a) show them the good URL and b) to not have to manually create new directories and files matching the good URL.
External redirection
Just as you might've thought - external redirection is the exact opposite of internal redirection.
External redirection is when one URL gets redirected to another one externally, with the user agent knowing of the change.
In external redirection the browser and user all know that one URL was redirected to another. In technical terms, unlike internal redirection, it does send a 301 or 302 response code to the browser which consequently updates its address bar to point to the new URL.
For a search engine such response codes can mean to transfer the ranking juice of the old URL to the new URL i.e all the SEO significance for the old URL gets transfered to the new URL.
Now on to why do we need external redirection...
Why do we need it?
This sort of redirection is used to unify the various URLs in which a website can be served.
For example consider the following URLs:
http://example.com
http://www.example.com
https://example.com
https://www.example.comAll of them point to the same page - we can write any one of them in the browser and it will take us to the same page under that specific URL. Four different URLs for one page, isn't it crazy!
And this is where external redirection can take charge by redirecting all other URLs to one, single prefered URL. In the example above it could mean to redirect all non-www and non-https URLs to https://www.example.com.