Jason Axelrod Jason Axelrod - 3 months ago 10
Apache Configuration Question

Redirect empty URL subdomain to different directory?

I have directories on my server such as:

mydomain.com/u/person1
mydomain.com/u/person2
mydomain.com/u/person3
etc...


Each of these directories has it's own username/password using .htaccess/htpasswd...

If someone tries to go to
mydomain.com/u[/]
, how can I get them to be forwarded to
mydomain.com/users
instead?

The reason for this is my domain is a no-index.html website; all the directories show Apache generated file trees (which I want). The
/u/
directory has 30+ password protected folders in it, and if anyone tries to go there, it tries to show a file tree of password protected directories and instantly bans the user from the server.

Answer

You can place this rule in /u/.htaccess:

RewriteEngine On

RewriteRule ^/?$ /users/ [L,R=301]