How to hide real directory name using htaccess? Print

  • mask dir, hide dir, mask url, hide files, rewrite
  • 3

Developers use to hide directory name from public so that bots or hacker won't find their website template/modules by running directory structure finding scripts. Once your website is beta ready & before you submit the website to search engines, you can hide your directory structures using htaccess file, so the browsers & visitors see masked directory name rather real directory name. This is one of the best security for your application based websites. Below we will try to mask: /template/mytemplate/media/css to /css using code below:

RewriteEngine On 
RewriteBase / 
RewriteRule ^css/(.+) /template/mytemplate/media/css/$1 [L,QSA]
 
You can keep on adding new lines to hide/mask any directory you want from public. Remember, we are using .htaccess file which is very sensitive about its rules & placement. Be sure to use a single .htaccess at root dir for each & every directory structures inside it.

Was this answer helpful?

« Back

Powered by WHMCompleteSolution