2012-06-14 42 views
1

现在我的URL格式如下:mod_rewrite的建议

http://domain.com/index.php?template=user&id=39

我使用this function创建独特的短字符串ID。

我想实现的是:http://domain.com/u/D/其中u是用户页面,D是由前面提到的函数生成的唯一短字符串。

这是我的尝试:

RewriteEngine On 

RewriteRule ^/(.*)/(.*)/$ index.php?template=$1&id=$2 [L] 
+0

是否'^重写规则/([^ /] +)/([^ /] +)/ $ /index.php?template=$1&id = $ 2 [NC,L]'为你工作? –

+0

我得到404没有找到 – bary

+0

'RewriteRule^/?(。*)/(。*)/?$ index.php?template = $ 1&id = $ 2 [L]' – undone

回答

0
RewriteEngine On 
RewriteRule ^(.*)/(.*)/?$ index.php?template=$1&id=$2 [L,QSA]