If you own or develop a website, you may wish to hide the exact file name of a page, image or other document when a user visits your website. If your hosting server uses Apache software, employ the mod_rewrite function in a Hyper Text Access file to instruct the server to display a different URL in the browser address bar when the visitor loads a specific file. This may be especially useful if you want to show the directory location but not the file name.
- Skill level:
- Moderately Easy
Other People Are Reading
Open a text editor such as Notepad on Windows.
Type, or copy and paste, the following into a blank document:
RewriteRule ^old.html$ new.html
Replace "old.html" with the file name you are trying to hide. For example, if you want to hide "page.html," type "page.html." The backslash instructs the server to treat the period between the file name and type as a regular character.
Replace "new.html" with a new file name such as "new.html" or directory such as "/directory." You do not need to include the backslash in this expression.
Open the file menu and choose the option to save. In the dialogue box, type "htaccess" as the file name and select "txt" as the file type.
Connect to your Web server. If using FTP, launch your FTP program on your computer and enter your login credential and server information before pressing "Connect."
Navigate to the directory that contains the file whose name you wish to hide in the "Remote Server" pane of your FTP client.
Open the folder on your computer that contains "htaccess.txt" in the "Local" pane of your program.
Double-click the file or right-click and choose "Upload" to upload it.
Right-click on the file in the remote pane and choose the option to rename it. Change the name to ".htaccess." The file may become hidden, depending on your server and FTP client settings. When users access the old URL, they will now see the new URL in their browser address bar.
Tips and warnings
- This method only works on Apache and compatible servers.
- Your Web host must turn on the mod_rewrite function or this will not work.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for