How to hide real directory name using htaccess?

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.
  • mask dir, hide dir, mask url, hide files, rewrite
  • 3 Users Found This Useful
Was this answer helpful?

Related Articles

How to block visitors by referrer domain using htaccess?

Being a website owner, you might have seen a lot of traffic coming from external websites to your...

How to block bad bots using htaccess?

There are hundreds of search engines, thousands of crawlers & bots do crawl your website which is...

How to change server default signature using htaccess?

There are chances where a bot or a user tries to access a non-existing page which shows default...

how to change your web servers date timezone using htaccess?

You may have hosted your website on a shared server where the DC located in a foreign country &...

How to prevent content & bandwidth theft using htaccess?

When you have a decent website with your own articles, images, media contents, clip arts etc....