I was wondering how to pass several (two) values through url as a clean url.
I’ve done clean urls before, but never with multiple values and it doesn’t seem to be working.
This is what the url looks like now:
http://example.com/?user=Username&page=1
This is what I want it to look like
http://example.com/user/Username/page/1
I’ve tried other answers that I’ve seen on here, but they aren’t working for this certain deal.
RewriteEngine On
# Don't match real existing files so CSS, scripts, images aren't rewritten
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
# Match the first two groups before / and send them to the query string
RewriteRule ^([^/]+)/([^/]+) index.php?user=$1&page=$2 [L]
Thanks. 🙂
I’m using PHP by the way. 🙂
Also, will I still be able to use $_GET with this? I thought so, but I also somewhere else where it said you can’t… 😀
You’re missing several matches, try:
This will take a URL like:
to the URI:
In the above example, when you look at
$_GET['a']you’d getb.