Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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]

share|improve this question
    
I suspect you need to look at mod_rewrite. –  Zoredache Dec 14 '12 at 0:52
    
@Zoredache I was hoping to avoid it, but I will if there's no other choice. Thanks for the tip anyway –  goncalopp Dec 14 '12 at 0:55
    
any particular reason to why you would rather avoid mod_rewrite? –  Mathias R. Jessen Dec 21 '12 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 –  goncalopp Dec 21 '12 at 23:49
add comment

1 Answer

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]
share|improve this answer
    
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! –  goncalopp Dec 28 '12 at 6:19
add comment

Your Answer

 
discard

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.