【发布时间】:2016-12-01 22:03:27
【问题描述】:
有没有办法让它工作?
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^/]+)$ index.php?a=1&b=2 [L]
RewriteRule ^([^/]+)/([^/]+)$ index.php?a=$1&c=$2 [L]
网址应如下所示:
http://test.com/a/b
or
http://test.com/a/c
它只适用于第一条规则。
就我而言,我正在尝试创建个人资料页面并通过会话 ID 或通过 $_GET['id'] 获取 ID。
因此,如果我访问其他人的个人资料,则 url 是
index.php?page=profile&id=25
/profile/25
如果我访问的是我自己的个人资料
index.php?page=profile
/profile
例如,我想编辑我的个人资料
index.php?page=profile&action=edit
/profile/edit
我希望你明白我的意思并能帮助我。
【问题讨论】:
-
我不确定您的两个 URL 之间有什么区别,即应该使用 a= 重定向一个?和 b =?另一个应该是 a=?和 c=?.
-
但这只是行不通,因为它总是试图到达 test.com/post/25
-
如果参数是这样的:test.com/index.php?page=post&action=edit 或 test.com/index.php?page=post&id=25
-
你能用更多的例子来更新这个问题吗?我想我开始明白你想要做什么了。 /post/edit 可能需要更改为 /post/25/edit 才能工作(否则我们怎么知道 ID?)
标签: .htaccess clean-urls