Wednesday

URL Masking With Apache rewrite

Rewriting URLs in a certain way with the .htaccess file can display web pages from a URL different than the URL in the browser's address bar. However, both the URL in the address bar and the web page being viewed must be located on the same domain as the .htaccess file.

There are no visual clues that the web page being displayed is not at the URL in the browser's address bar unless the web page being displayed itself contains clues.

There are many nuances to consider when writing URL redirect lines for the .htaccess file. Consider testing with an .htaccess file in an otherwise unused subdirectory before going live.

Here is a simple directive that will rewrite all URLs for any documents in the /free directory so the /paid/index.html will display, instead. The URL in the browser's address bar will be the original URL to a document in the /free directory. Yet, web page /paid/index.html is being viewed.

If the web page being viewed is at a domain different than where the .htaccess file is located, the URL in the browser's address bar will change.

Probably the most authoritative reference for URL rewriting is the "URL Rewriting Guide" at the apache.org site. Other web sites also have tutorials and guides, some of which may be easier to learn from than apache.org's guide. To get a list, do a search for:
"URL rewrite" +tutorial

No comments:

LLM for Humanoid Robot

  Photo by Tara Winstead Let's consider a scenario where we aim to integrate Long-Term Memory (LLM) into a humanoid robot to enhance its...