Thursday, December 31, 2020

Is a redirect a type of rewrite rule?

I'm trying to understand the difference between a rewrite and a redirect and I'm a bit confused. I've read in some places that the difference is "A Redirect rule instructs the client (usually a browser) to switch URLs and navigate to the destination of the rule. Redirect rules are typically used for old paths that you’d like to redirect to new ones.

In contrast, a Rewrite rule does not change the original URL; it simply serves the content of the rule destination at the original path. The browser can not tell that the content was served from a different path or URL, making it possible to display content from a different path or URL on any other path on your site. "

But looking into Apache Servers, the documentation says this: "The mod_rewrite module uses a rule-based rewriting engine, based on a PCRE regular-expression parser, to rewrite requested URLs on the fly. By default, mod_rewrite maps a URL to a filesystem path. However, it can also be used to redirect one URL to another URL, or to invoke an internal proxy fetch."

So in this case can rewrites function as redirect such that the URL will appear to change in the browser? Or is it always the case that if it's a rewrite, the browser url will never change? Is it a different answer if you're using IIS vs Apache Server perhaps?



No comments:

Post a Comment