mod_userdir seems to be able customize where the home folders are, but is there a way to make those available under a custom URL?

I want to provide users with a url like the following: http://example.com/arbitrarystring/[user]

  • I suspect you need to look at mod_rewrite.
    – Zoredache
    Dec 14, 2012 at 0:52
  • @Zoredache I was hoping to avoid it, but I will if there's no other choice. Thanks for the tip anyway Dec 14, 2012 at 0:55
  • any particular reason to why you would rather avoid mod_rewrite? Dec 21, 2012 at 23:43
  • @MathiasR.Jessen Since mod_rewrite is such a complex module, I assume (perhaps mistakenly) that it'll be so much easier to come up with an insecure configuration. Also, I imagine there's some performance hit, though that's not particularly relevant in my usecase. mod_userdir just seems tailor-made for this purpose, and I keep wondering why it's still there (in apache) if mod_rewrite is capable of emulating it (which I know it does). I'll readily accept a mod_rewrite answer here, if there's really no other choice Dec 21, 2012 at 23:49

1 Answer 1


This is entirely doable. I did just that and recorded the efforts here. This is a solution that does use mod-rewrite, but not deep wizardry. The problem we had was that when we were implementing user_dirs, The Powers That Be thought using a shift key to get at a directory was too much work and wanted a tilde-free version. That's a one character version of what you're doing.

The meat is in the RewriteRule statements.

RewriteRule  ^/somestring/([a-z0-9]+)         /~$1    [R]

The problem here is that /~username will still work. You can possibly get around that by using an internal proxy-redirect to another hidden domain name.

RewriteRule ^/somestring/(a-z0-9]+)        http://othervhost.example.com/~$1      [PT]
  • Since no one came up with an answer using just mod_userdir, and your solution is well documented, I'm awarding you the bounty. Thanks for sharing! Dec 28, 2012 at 6:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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