1

I can't seem to obtain the second part of the url slug. I currently have my .htaccess file like this:

RewriteEngine on
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?id=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?id=$1

And get this:

http://example.com/user/john

And now can't get this to work:

 http://example.com/user/john?o=last

How can I obtain $_GET['o']?

4

1 回答 1

1
  1. 您需要 QSA(查询字符串附加)标志来在重定向时保留现有查询。
  2. 您不需要 2 条规则来处理斜杠。

用这个替换你的代码:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^([a-z0-9_-]+)/?$ /index.php?id=$1 [L,QSA,NC]
于 2013-06-28T06:31:16.363 回答