Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What is a rewrite rule?

rewrite rule
0
Posted

What is a rewrite rule?

0

A rewrite rule is a way that Apache can rewrite an incoming request “on the fly”. In essence, a user can ask a webserver for one file, and the webserver can serve up a completely different file to the user instead. Isn’t this like a redirect? No, a redirect is when the webserver tells a user, “that’s not the file you want, you need to go over here”, at which point the browser loads the new URL. Redirects aren’t always desirable, especially of the files/PHP scripts/whatever are currently living a temporary location. Why would I want to use one? Let’s say you’re installing an app that somebody else wrote, and the app lives under /very-long-application-name. You could use a rewrite rule so that users could go to /short-app-name, and Apache would rewrite that request behind the user’s back to be /very-long-application-name. And the best part is that this is transparent to a properly built application. Another example is maybe you’re starting up a video “tube” site, and you want to have the

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.