我想重写www.mysite.com/a/b/slug
为www.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} !-f
和RewriteCond %{REQUEST_FILENAME} !-d
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句