Forum Moderators: phranque
Options +SymLinksifOwnerMatch
RewriteEngine On
RewriteRule ^[\.0-9-a-z]+/([-a-z]+)/p([0-9]+)pg([0-9]+)\.html$ index.php?p=$2&c=$3&k=$1 [NC,QSA,L]
RewriteCond %{HTTP_HOST} ^[.+].example.com/([-a-z]+)/[.+]$ [NC]
RewriteRule ^[\.0-9,:\/-a-z]+p([0-9]+)c([0-9]+)\.html$ index.php?p=$1&c=$2&k=%1 [NC,QSA,L]
[edited by: phranque at 1:01 pm (utc) on May 11, 2013]
[edit reason] exemplified hostnames and keywords [/edit]
^[\.0-9-a-z]+/([-a-z]+)/ p([0-9]+)pg([0-9]+)\.html$ RewriteRule ^([^/]+)/p(\d+)c(\d+)\.html$ index.php?p=$2&c=$3&k=$1 [NC,QSA,L] [^/]+ means one or more non-slash characters. In other words, this matches a path segment. And \d is a shortcut for [0-9].
Now the data I want to collect in variables is the portion after "www.example.com/" so in this case
I want "monster-bikes" and "p1c9"
Then using the collected variables the server can redirect to:
"example.com/index.php?p=1&c=9&k=monster-bikes"
{snip}
RewriteRule ^[\.0-9-a-z]+/([-a-z]+)/p([0-9]+)pg([0-9]+)\.html$ index.php?p=$2&c=$3&k=$1 [NC,QSA,L]
[\.0-9-a-z]+/ ([-a-z]+)/p([0-9]+)pg([0-9]+)\.html$