When to ReWrite and when to Redirect – .com

Both are a small instruction in an .htaccess file, although what they do are dangerously similar, it is not the same to do a Redirect as a ReWrite. Let’s see the difference, to know when we have to use one or the other.

As I was saying, both are written to the .htaccess file. Any request that is made to the server goes through this file. That means that every time we load a page it goes through this file multiple times; to read the HTML, for each style sheet, for each .js, and even for each image (among other things).

So that, every time we enter a URL in the browser, it goes through the RewriteRules filters that we have in the -htaccess. If it “fits” with the rules that we have established, the server “transforms” the URL. That does not mean that it redirects it to another page, it simply transforms it to another URL. In the case that you want to do that, you must incorporate the flag . But then… what differentiates it from a Redirect?

The Redirect (or 301 redirect), is a way of telling Google that that page has moved forever. That it is no longer there, that now it will always be somewhere else, that this change will be permanent, and that from now on it is best to always go directly to the new direction.

On the other hand, in the case of doing it with a rewrite, we are simply “dressing up” the URL, to make it more beautiful and to be better indexed in search engines. In other words, instead of something like “https:///?p=423” the URL is “https:///seo-services”. Much more descriptive than a “p” parameter assigning an autonumber code.

See also  How to use special fonts on a website - .com

So, we’ll use Redirect when we’ve simply changed our site content, and we’ll use ReWrite when we want to make up the URL. Using ReWrite as a redirect (adding the ) It would only apply in cases where we want to apply , since if it is simply a redirect, it is not necessary to use it.

Loading Facebook Comments ...
Loading Disqus Comments ...