无法将路径信息移动到 htaccess 中的查询字符串

米奇

我想重写www.mysite.com/a/b/slugwww.mysite.com/a/b/index.php?id=slug.

我正在尝试捕获路径的最后一段 ieslug并在查询字符串中使用它 - 类似于此示例

所以,我在我的下面几行.htaccess坐我的public_html文件夹:

RewriteEngine on
RewriteRule ^a/b/([^/]+) a/b/index.php?id=$1 [L]

在我a/b/index.php,当我去www.site.com/a/b/slug$_GET['id']回报index.php反对slug我不知道为什么。

如何捕获最后一个段并在查询字符串中使用它?

卢克

您需要在 .htaccess 中添加重写条件 - 目前,它/a/b/index.php也在尝试重写

尝试添加RewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-d

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章