Forum Moderators: phranque
Assuming that this code goes into httpd.conf, and that all usernames start with "~", what you've got should work in most cases. You could make it a little more efficient, prevent recursion, and remove the trailing slash ambiguity with:
RewriteCond %{REQUEST_URI} !^/users
RewriteRule ^/~(([a-z])[^/]+)(.*) /users/$2/$1$3 [L]
For those just tuning in to mod_rewrite, back-references are assigned according to the left parenthese's nesting order. Therefore, nevsk's $2 contains only the first letter of the username, while $1 contains the entire username -- that is, everything up to the first slash.
Jim
www.example.com/petra/page1.html -> www.example.com/users/p/petra/page1.html :
RewriteCond %{REQUEST_URI} !^/users
RewriteRule ^(([a-z])[^/]+)(.*) /users/$2/$1$3 [L]
im using the following rules and it appears to be working
RewriteEngine On
RewriteCond %{REQUEST_URI}!^/(cgi-bin¦css¦images¦include¦paypal¦scripts¦vdaemon¦users)/
RewriteCond %{REQUEST_URI}!\.(php¦gif¦jp?eg¦png)$
RewriteRule ^(([a-z])[^/]+)(.*) /users/$2/$1$3 [L]
Tks again!
nevsk