Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am setting up a new server for our users to use have have personal webspace on. I have in my httpd.conf of apache the directives for UserDir as follows

UserDir disabled root
UserDir public_html

This has allowed http://myserver/~user/ requests to work but I am also looking to set it up so the pages can be accessed via http://myserver/users/username.

How can this be done? I had thought about mod_rewrite rule but have thus far been unsuccessful.

EDIT: Essentially I am looking to take the http://myserver/users/username requests and either point them or rewrite them to http://myserver/~user/. whether it changes in the address bar is irrelevant at this time.

share|improve this question

Here is somebody that managed to use rewrite rules to remove the tilde completely:

I've modified what they did to put the "users" directory in.

RewriteEngine On
#RewriteLog logs/rewrite.log # Uncomment for rewrite logging
#RewriteLogLevel 3 # uncomment for verbose logging
RewriteCond %{REQUEST_URI} ^/users/([^/]+)
RewriteCond /home/%1 -d
RewriteRule ^/([^/]+)(.*) /home/$1/public_html/$2

Here is a thread at WebmasterWorld.com where somebody wanted to redirect away from the version with the tilde: http://www.webmasterworld.com/apache/4362132.htm

If you wanted to redirect away from the tilde version, you would have to use something like this. These rewrite rules are meant to go into each users .htaccess

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /~mysite
RewriteRule (.*) http://example.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} !^(example\.com)?$
RewriteRule (.*) http://example.com/$1 [R=301,L]
share|improve this answer
The first part looks like what I need however it does not appear to be working as intended. I am still trouble shooting it but as of currently writing it does not rewrite http://myserver/user/test/index.html to http://myserver/~test/index.html it just states the page cannot be found – Spartan-196 Feb 19 '13 at 15:41
I put in /users/ not /user/. Also that rewrite rule is meant to work in your httpd.conf file not in a .htaccess file because the rules start with /, make sure you are putting the rewrite rules in httpd.conf and restarting the server. – Stephen Ostermiller Feb 19 '13 at 15:44
That was a typeo on my part. I am using /users/ Nothing is being logged to the log and browsers just return a 404 The requested URL /users/test/index.html was not found on this server – Spartan-196 Feb 19 '13 at 15:48
Thats as much help as I can provide then. I hope you get another answer that works for you. – Stephen Ostermiller Feb 19 '13 at 15:58
I think it is still the right path. Thank you for your assistance. IF I could up vote I would. – Spartan-196 Feb 19 '13 at 16:05
up vote 0 down vote accepted

I have consulted some older colleagues of mine and we have found that the rule I was looking for was:

RewriteRule ^/users/(.*)$ /~\$1 [R]

If I were using Alias matching I would need:

AliasMatch (^[A-Za-z0-9])
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.