Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

user directory redirect, .htaccess

Status
Not open for further replies.

bwalker99

Technical User
Oct 16, 2006
2
US
Hi, I'm relatively inexperienced with .htaccess redirects, but I've done a few. Our website was recently relocated offsite. The old web server featured user directories that could be reached using the followig format (emphasis on the tilda(~):

Before transferring the domain I tested some redirect rules on the new server to make sure that they would work, and they did. Here is the format I used:
RewriteRule ^~user
(Note:Keep in mind that each user established their own site so not all of the ~users moved to the same so I couldn't just do a general rule for all.)

Once the domain was redirected to the new server, this format worked for a few of them, but most of them returned a 404 error and none of them would redirect. I've been desperately looking for a remedy, as currently there is no effective redirect in place, and no luck so far. Here are some of the other formats I've tried:

RewriteBase /~user
RewriteCond %{ -d
RewriteRule ^(.+[^/])$ $1/ [R]##I think this just adds the trailing slash
###### DID NOT WORK


#RewriteRule ^/~([^/]+)/user$ [R]
###### DID NOT WORK

Any suggestions would be GREATLY appreciated.
 
I wanted to add that I found the following on apache.org which specifically relates to my problem, but I'm not sure how to adapt it for use on a case by case basis...

Description:
Some sites with thousands of users usually use a structured homedir layout, i.e. each homedir is in a subdirectory which begins for instance with the first character of the username. So, /~foo/anypath is /home/f/foo/. while /~bar/anypath is /home/b/bar/.
Solution:
We use the following ruleset to expand the tilde URLs into exactly the above layout.

RewriteEngine on
RewriteRule ^/~(([a-z])[a-z0-9]+)(.*) /home/$2/$1/.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top