0

Is there any easy/faster way to change url like

http://example.com/profile.php?id=52 

to

http://example.com/profile/52/username

If I have $row['id'] and $row['username'] from database?

I tried,

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

But, it seems that number/username part is pretty confusing.

4

1 回答 1

1

Change the rule to this to assign only the number to $1:

RewriteRule ^profile/([0-9]*)$ /profile.php?id=$1 [QSA,L]
于 2013-10-02T19:46:59.583 回答