[.htaccess] Rewrite url with multiple variables
i'm trying to make a .htaccess file to produce some fancy urls, but i can't get it fully working.
The problem is that i have multiple variables and different possibilities with those variables. All links are pointing to index.php, which handles the pages to load by variables in the url.
To be more clear, i have:
- p for page (register, home etc.)
- cat for category
- step for registration steps
- maybe i'll put another variable in later on
So there are multiple possibilities, like index.php?p=home, index.php?p=cat&cat=1 or index.php?p=register&step=2.
I can get the .htaccess file to work for 1 and two variable, but when i put multiple rules for the different variables i can't. It looks like this right now:
I tried to put another rule above the first rewriterule, like this:
RewriteRule ^([a-z0-9_-]+)/([a-z0-9_-]+)(/)?$ index.php?p=$1&cat=$2
RewriteRule ^([a-z0-9_-]+)(/)?$ index.php?p=$1 [L]
RewriteRule ^([a-z0-9_-]+)/([a-z0-9_-]+)(/)?$ index.php?p=$1&step=$2
But then the combination ?p=$1&step=$2 works, but ?p=$1&cat=$2 doesn't. I can't really figure out how to get it to work. I read some tutorials, and they just told me to add another rule. Could somebody please advise me?
Bump.... Can nobody help me out? Even a little bit?
Place the [L] flag after the first rule. If the server matches at the first rule, it will stop.
The [L] flag means "last" as in, if the server matches this rule, let it be the last one (don't try to match another one after it).
I've switched careers...
I'm NO LONGER a scientist,
but now a web developer...
Users Browsing this Thread
There are currently 1 users browsing this thread.
(0 members and 1 guests)
Tags for this Thread