1

I have this code somewhere in my .htaccess file:

RewriteRule /user/([a-zA-Z0-9]+) /iduser.php?username=$1

It should make /user/oliolio request iduser.php?username=oliolio, however it doesn't work. :(

Do you know why?

1
  • Can you confirm that rewrite rules are working over all, too?
    – Gavin C
    Jun 2, 2011 at 11:32

2 Answers 2

3
RewriteRule ^(.*)/user/([a-zA-Z0-9]+)$ /iduser.php?username=$2 [L]

Or if its just yourdomain.com/user/ollio then

 RewriteRule ^user/([a-zA-Z0-9]+)$ /iduser.php?username=$1 [L]

Make sure RewriteEngine On is set

1
  • Appreciate that you kept the asker's character/number restriction in the regex, but might want to simplify to using [a-z0-9] and adding the "nocase / NC" directive
    – Gavin C
    Jun 2, 2011 at 11:30
3

Have your rule like this:

RewriteRule ^user/(.*)/?$ /iduser.php?username=$1 [QSA,NC,L]

Apache strips out leading slash / that's why your rule is not working.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .