.htaccess用get参数重写url

闪光灯12

这是我第一次尝试.htaccess

这就是我要的。

example.com/account/blitzen12 -> example.com/account/index.php?id=10&name=blitzen12

我不想在重写中包含ID,这可能吗?

Note: id and name which is 10 and blitzen12 is retrive from the database.

到目前为止,这是我尝试过的方法,但没有奏效。

Options +FollowSymLinks  
RewriteEngine On 

RewriteRule ^account/(.*)$ ./account/index.php?page=account&id=$1&name=$2 [L,NC]

html代码。

<a href="account/index.php?id=10&name=blitzen12">blitzen12</a>

谁能帮我这个?谢谢你。

林俊

“ 10”或ID并非URL的一部分:

example.com/account/blitzen12

因此,您不能将其重写为另一个URL,也不能凭空拔出它。您可能只需要提供不带“ id”的页面(并使用“ name”将其拉出数据库),或者将其嵌入没有查询字符串的URL中,例如:

example.com/account/10/blitzen12

那么您将可以使用以下代码将其重写:

Options +FollowSymLinks  
RewriteEngine On 

RewriteRule ^account/([0-9]+)/(.*)$ ./account/index.php?page=account&id=$1&name=$2 [L,NC]

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章