How to Cloak URL on Redirect

by Benjamin Aries
A cloaked URL redirects traffic on a web server.

A cloaked URL redirects traffic on a web server.

URL masking, also known as URL cloaking, is a method that is used to redirect website visitors to a new location on the Internet. Normally, a web user can see the actual URL address for the current page in a web browser. With a cloaked URL, however, data from a second location is displayed even though the URL address does not appear to change in the browser. This technique is commonly used when web pages change location, but webmasters do not wish to confuse visitors by changing existing links.

1

Create an HTACCESS file to control the URL redirect. Open Notepad or another simple text editor. Click "File" and then "Save As." Select "All Files" from the "Save As Type" drop down menu. In the "File Name" field, enter ".htaccess" and click "Save." Note that the period before "htaccess" is required.

2

Enter code into the newly-created HTACCESS text document. Type "RewriteEngine On" for the first line. On the next line, enter "RewriteCond %{REQUEST_URI} ^/exampleone($|/)" and replace "exampleone" with the host directory name that will be cloaked. Type "RewriteRule ^.*$ /exampletwo/index.html [L]" on the third text line. Use the actual destination folder or URL in place of "exampletwo."

3

Click "File" and then "Save" to store the modifications to the HTACCESS document. Launch the FTP transfer program for the website. Locate the local folder that holds the saved HTACCESS file, and upload this file to the root directory of the website.

4

Open a web browser and test that the URL redirect masking works correctly. For the example listed here, type "http://www.example.com/exampleone" and press enter. Verify that this address is shown in the browser bar, even though the content at "http://www.example.com/exampletwo/index.html" is actually displayed.

Warning

  • close URL masking and redirection is a complex topic and should only be used by webmasters who are comfortable with hosting and server terminology. Improper HTACCESS use can cause problems with a website and rewrite rules should be used carefully.

Items you will need

About the Author

Benjamin Aries has been involved in digital media for much of his life and began writing professionally in 2009. He has lived in several different states and countries, and currently writes while exploring different parts of the world. Aries specializes in technical subjects. He attended Florida State University.

Photo Credits

  • photo_camera Comstock/Comstock/Getty Images