.htaccess - hide directory from users' address bar

trol

New member
Joined
Jul 17, 2024
Messages
2
Points
1
Hello,
i would be grateful if i can get some help with this issue.
i have a parent directory for a domain that has sub directories for each user.
in this i would like to find out if i need a separate .htaccess file for each sub directory belonging to the users.

also i would like to hide a directory from the users' view in the address bar.
each user sub directory has a separate sub domain

so if a user domain is sub.mydomain.com,
and the user accesses sub.mydomain.com/files/product.php,

i want the user to see this instead sub.mydomain.com/product.php,

even though the direcctory files exists and serves files, i want it hidden from the user's view.
 

Nemanja

Premium Member
Joined
Nov 23, 2012
Messages
299
Points
28
Hey there! You can use a single .htaccess file in your parent directory to manage all the subdirectories for users. Just set up rules in the parent .htaccess file to handle each subdomain and its respective directory.

To hide the /files/ directory from the URL, you can use mod_rewrite rules. Here’s a basic example for your .htaccess file:

Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^sub\.mydomain\.com$
RewriteCond %{REQUEST_URI} !^/files/
RewriteRule ^(.*)$ /files/$1 [L]
This rule rewrites URLs, so when a user accesses sub.mydomain.com/product.php, the server fetches sub.mydomain.com/files/product.php without showing /files/ in the URL. This way, your directory structure stays hidden.
 
Newer threads
Replies
10
Views
2,299
Replies
4
Views
2,700
Replies
0
Views
514
Replies
1
Views
646
Latest threads
Replies
2
Views
388
Replies
2
Views
776
Replies
1
Views
186
Recommended threads

Latest postsNew threads

Referral contests

Referral link for :

Sponsors

Popular tags

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top