【发布时间】:2022-01-01 02:28:58
【问题描述】:
由于某种原因,我无法访问仅用于 .htaccess 中的内部重写的查询值?
Options +FollowSymLinks
RewriteEngine ON
RewriteBase /
##external redirect
RewriteCond %{QUERY_STRING} ^id=([0-9]*)$
RewriteRule ^(.*)$ /test/user-profile/%1? [R=301,L]
#internal rewrite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(.*)/(.*)$ /test/user-profile.php?id=$3 [L]
这是整个 htaccess 文件。它完美地重定向了url,只是不能自己获取id值?谢谢
【问题讨论】:
-
您请求什么网址?预期的 URL 目标是什么?
-
请求
www.example.com/test/user-profile?id=1然后我希望 url 以www.example.com/test/user-profile/1的形式显示给用户,然后仍然可以通过 PHP 提取 id 值
标签: php apache .htaccess config