Php Apache mod_rewrite:我做错了什么?

Php Apache mod_rewrite:我做错了什么?,php,apache,mod-rewrite,friendly-url,Php,Apache,Mod Rewrite,Friendly Url,我在.htaccess文件中有一个非常简单的重写,但它并没有完全按照我想要的方式工作。这是我的代码: <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^admin/?$ admin.php [L] RewriteRule ^([0-9]*).*$ index.php?id=$1 [L] </IfModule> 重新启动发动机 重写规则^admin/?$admin.php[L] 重写规则

我在.htaccess文件中有一个非常简单的重写,但它并没有完全按照我想要的方式工作。这是我的代码:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^admin/?$ admin.php [L]
    RewriteRule ^([0-9]*).*$ index.php?id=$1 [L]
</IfModule>

重新启动发动机
重写规则^admin/?$admin.php[L]
重写规则^([0-9]*).$index.php?id=$1[L]
基本上我想要的是每个页面都是这样的:/0/标题。标题只是为了让用户更清楚地了解URL,但是数字(id)应该传递给我的PHP脚本。使用此代码,id不会传递给我的index.php脚本。如果我只是从第四行删除“*”,它就会被传递到该脚本,但是数字后面带有文本的URL不会被传递到我的index.php文件中

我做错了什么?我怎样才能解决这个问题


谢谢

您试图捕获类似
/0/title
的URL,但您的匹配模式中没有斜杠
/
。请尝试以下方法:

# Should match /01234/anything
# with the "/anything" optional
RewriteRule ^([0-9]+)(/.*)?$ index.php?id=$1 [L]

您想将index.php命名为
index.php?id=0
还是类似于
index.php?id=0&t=title