Difference between URL Rewrite and URL Redirect
Most people have only the most cursory knowledge about URL rewrites and redirects. Many simply put them into use and even recommend them to other people without a having a deeper understanding of how they really work. While this is sufficient for most purposes, there are times when a more in depth understanding of these two terms would be beneficial. If you have ever wondered what functions these may have aside from enhancing your SEO and permanently redirecting pages, this is the place to find out!
First of all, it is important to note that a rewrite is a server side operation, which simply means that the rewrite is done at the server. This may result in a static page, a dynamic page, or an image file. In any case, the rewrite is not apparent from the browser. With a URL rewrite in effect for example, the link clicked on in a browser may be substituted for another, without the searcher aware of the change. Even the URL seen in the browser will reflect the original site request.
A redirect on the other hand involves sending a response to the client immediately, using a new URL. In this case, the browser is presented with a 301 or 302 reply, which means that the site has been moved permanently or temporarily. The redirect also causes the new URL to show up in the address bar of the browser.
With a URL rewrite, the URL displayed in the browser is actually changed, although the code itself stays the same. The server will then essentially still read the original URL. The process of a URL rewrite goes as follows:
- User ends up on new URL
- The new URL points to the old one
- The code from the old URL is called by the server
- The new page with the new URL is then shown in the browser
After the rewriting of the URL, the redirect is then implemented in order to give the user the link to the newer site. This makes for a much better browsing example than simply being presented with a 404 error page with no alternative link provided. The process for a 301 redirect goes as follows:
- User ends up on original URL
- The 301 redirects the URL to the new one
- The URL displayed in the browser is changed to the new one
- URL Rewrite process starts up again
Using Both Together
As you can see, the URL rewrite and redirect are often used in tandem with each other. In all such cases, rules will typically be applied, under which requests that are perceived as erroneous will be redirected to a "Not Found" page, while requests that are considered "correct" will be rewritten on the server side.
Similarities and Differences
- Is a server side operation
- Rewrite is done at the server
- May result in a static page, a dynamic page, or an image file
- Sends a response to the client immediately, using a new URL
- Causes the new URL to show up in the address bar of the browser