2013-06-27 57 views
1

我似乎无法获得url slug的第二部分。目前,我有我的.htaccess文件是这样的:问题与URL slug。

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

而得到这样的:

http://example.com/user/john 

现在还不能得到这个工作:

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

我怎样才能获得$_GET['o']

+2

http://stackoverflow.com/a/11760282/1628832? – karthikr

+0

我如何才能让我的网址像这样工作? http://example.com/user/john/last – Brian

+0

你想要重定向到的URL是什么?是用户/约翰真实文件夹?什么是原始网址? –

回答

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]