user1692333
user1692333

Reputation: 2597

How to properly rewrite a friendly URL?

I have a URL like index.php?url_id=u5531e3aas01fe5c2 and I also want to make it work like /u5531e3aas01fe5c2, that it to pass a parameter to my PHP, but something is wrong with my code.

RewriteEngine On
RewriteBase /try/
RewriteRule /u[a-z0-9]{17} /index.php?url_id=$1 [L,QSA]

P.S. And also is it possible to rewrite URL that if appears index.php?url_id=u5531e3aas01fe5c2, it would be rewritten to /u5531e3aas01fe5c2

Upvotes: 1

Views: 98

Answers (1)

Mahdi
Mahdi

Reputation: 9417

Try this:

RewriteRule ^u([a-z0-9]{16}) /index.php?url_id=$1 [L,QSA]

Upvotes: 1

Related Questions