0

This seems simple, but I wasn't able to do it.

I have a user that changed his username from givenname to name, and now I need to rewrite, changing the URL on the clients, to avoid 404 errors on ~givenname.

I thought I could do something like this:

RewriteEngine on
RewriteBase /~givenname/
RewriteRule ^~givenname/([^/]+)$ ~name/$1 [R=301,L]

But I was unable to do this.

I'm aware that mod_userdir looks for specific user info on Unix files (/etc/passwd) or whatever is specified on /etc/nsswitch.conf, but there's a way to trick it and redirect to the new username?

Thanks.

PS: I'm running a little old Apache 2.2.16 server.

Vinícius Ferrão
  • 5,400
  • 10
  • 52
  • 91

1 Answers1

1

You could disable the mod_userdir feature for the former username:

UserDir disabled givenname

After that you could simply use mod_alias for the redirection:

Redirect "/~givenname" "/~name"

Please upgrade to Apache 2.4 as soon as possible: Apache 2.2 hasn't got updates after 2017, and the 2.2.16 is from July 2010!

Esa Jokinen
  • 43,252
  • 2
  • 75
  • 122