简体   繁体   English

如何正确重写友好的URL?

[英]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. 我有一个类似index.php?url_id=u5531e3aas01fe5c2的URL,并且我也想使它像/u5531e3aas01fe5c2一样工作,它将参数传递给我的PHP,但是我的代码有问题。

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

PS And also is it possible to rewrite URL that if appears index.php?url_id=u5531e3aas01fe5c2 , it would be rewritten to /u5531e3aas01fe5c2 PS并且也可以重写URL,如果出现index.php?url_id=u5531e3aas01fe5c2 ,它将被重写为/u5531e3aas01fe5c2

尝试这个:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM