Trying to get the first match as a username with a RewriteRule
I can't find the way to get the first mach after the slash as a user in
every URL request, for example:
http://mysite.com/USER/modules/test/script.php
to --> http://mysite.com/modules/test/script.php?u=USER
or
http://mysite.com/USER/modules/test/path/to/other/script.php
to http://mysite.com/modules/test/path/to/other/script.php?u=USER
I dont know if it's possible, but I think it must be. This is my .htaccess
after several tries:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^http://mysite\.com/(.+?)$
RewriteRule ^.*$ http://mysite.com/$0?u=%1 [R,L]
Where %1 is the username after the first slash, and $0 is the variable
real path to each script.
Thanks in advance and sorry for my poor inglish!
No comments:
Post a Comment