【发布时间】:2019-09-16 10:24:03
【问题描述】:
有人可以帮我将 url id 从 www.website.com/script/?id=3 重写为 www.website.com/script/3/
表示要去掉id=?id。
这是我的 .htaccess 文件代码:
RewriteEngine on
RewriteRule ^script/([^/\.]+)/?$ script.php?id=$1 [L]
【问题讨论】:
-
规则似乎没问题。确切的问题是什么?你有你的
AllowOverride设置,所以Apache 会读取.htaccess文件吗? PS。它将www.website.com/script/3/重写为www.website.com/script/?id=3,而不是将www.website.com/script/?id=3重写为www.website.com/script/3/ -
AllowOVERride 已设置。 .htaccess 文件正在工作。我最近尝试从 URL 中删除
.php,它成功了。
标签: php .htaccess url hyperlink