I would like to rewrite www.mysite.com/a/b/slug
to www.mysite.com/a/b/index.php?id=slug
.
I am trying to capture the last segment of the path i.e. slug
and use it in the query string -- similar to this example.
So I have the following lines in my .htaccess
sitting in my public_html
folder:
RewriteEngine on
RewriteRule ^a/b/([^/]+) a/b/index.php?id=$1 [L]
In my a/b/index.php
, when I go to www.site.com/a/b/slug
, $_GET['id']
returns index.php
opposed to slug
. I am not sure why.
How can I capture the last segment and use it in the query string?