Php .htaccess用get参数重写url
这是我第一次尝试.htaccess 这就是我想要的Php .htaccess用get参数重写url,php,apache,.htaccess,mod-rewrite,Php,Apache,.htaccess,Mod Rewrite,这是我第一次尝试.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 +FollowSymLi
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”的页面(并使用“名称”将其从数据库中拉出),要么将其嵌入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]
我试过你上面提到的方法,但没用。作为参考,我将编辑并包括html。是否可以重写html响应?我不确定这是否叫做出站规则?@blitzen12:mod_rewrite对到达服务器的请求有效;它与HTML没有任何关系。如果您希望HTML中的链接URL具有特定的形式,那么您必须确保它们具有该形式。