I've been working on this for a couple of days now and I'm wondering if anyone could point me in the right direction please... I'm trying to pass two variables in my rewrite.
Unless the given url is a file or directory, I'd like all urls to be dynamically rewritten as follows:
example.com/category -> example.com/index.php?p=category
example.com/category/page -> example.com/index.php?p=category&article=page
example.com/category2/page -> example.com/index.php?p=category2&article=page
I'm having a hard time trying to turn the following in something dynamic:
RewriteRule ^category/(.+?)$ ?p=category&article=$1 [L]
I'm trying this but it doesnt work:
RewriteRule ^(.+?)/(.+?)$ ?p=$1&article=$2 [L]
...also trying this but it doesnt work either:
RewriteRule ^(.*)/(.+?)$ ?p=$1&article=$2 [L]
I'm trying to avoid putting in the following to make it work:
RewriteRule ^category2/(.+?)$ ?p=category2&article=$1 [L]
Here is the full code:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^category/(.+?)$ ?p=category&article=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ?p=$1 [L]
UPDATE:
This actually did it for me:
RewriteRule ^([^/]+)(/([^/]+))? ?p=$1&article=$2 [L]
Thank you!! Andrew



$2is outputting the second parameter "page" in the OP correctly? I think it'll output "/page" instead