1

I am trying to create user-friendly URLs for my users profiles. For example, elena93, is a user. And to go to her profile, you can simply go to: http://mysite.com/elena93

I know how to achieve this using htaccess:

RewriteEngine on
RewriteRule ^([^//]+)$ user.php?id=$1 [QSA,L]

The above code works, but the problem is, I have rewritten urls for other pages too. Like, home.php can be accessed using http://mysite.com/home, messages.php can be accessed using http://mysite.com/messages. When I set up the user-friendly profile links, rewritten urls for home, messages, etc pages stops working.

How do I fix that? Thank you!

4

1 回答 1

0
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^//]+)$ user.php?id=$1 [QSA,L]

That will exclude existing files.

于 2013-08-30T12:45:29.637 回答