Page 1 of 1

mod_rewrite/regex issue - can anyone take a look please?

Posted: Mon Jul 03, 2006 6:51 am
by nutkenz
This is my .htaccess file:

Code: Select all

Options -MultiViews

RewriteEngine On

RewriteBase /testing/

RewriteRule ^product/(.*).html$ products.php?q=$1&rewrite=1&%{QUERY_STRING} [L]

RewriteRule ^review/(.*).html$ reviews.php?q=$1&rewrite=1&%{QUERY_STRING} [L]

RewriteRule ^merchant/$ merchants.php
RewriteRule ^merchant/(.*)/$ search.php?q=merchant:$1:&rewrite=1%{QUERY_STRING} [L]
RewriteRule ^merchant/(.*)/(.*).html$ search.php?q=merchant:$1:&page=$2&rewrite=1%{QUERY_STRING} [L]

RewriteRule ^brand/$ brands.php
RewriteRule ^brand/(.*)/$ search.php?q=brand:$1:&rewrite=1%{QUERY_STRING} [L]
RewriteRule ^brand/(.*)/(.*).html$ search.php?q=brand:$1:&page=$2&rewrite=1%{QUERY_STRING} [L]

RewriteRule ^category/$ categories.php
RewriteRule ^category/(.*)/(.*)/$ search.php?cat=$1&subcat=$2&q=category:$2:&rewrite=1%{QUERY_STRING} [L]
RewriteRule ^category/(.*)/(.*)/(.*).html$ search.php?cat=$1&subcat=$2&page=$3&q=category:$2:&rewrite=1%{QUERY_STRING} [L]

RewriteRule ^shop/$ index2.php
RewriteRule ^shop/(.*)/$ index2.php?cat=$1&subcat=none&rewrite=1%{QUERY_STRING} [L]
RewriteRule ^shop/([a-z]+)/([a-z]+)/$ index2.php?cat=$1&subcat=$2&rewrite=1%{QUERY_STRING} [L]
This is the URL I'm visiting: .../testing/shop/computer/printen/

These are the arguments in the actual URL: Array ( [0] => cat=computer/printen&subcat=none&rewrite=1 )

When I drop the trailing / as in : RewriteRule ^shop/([a-z]+)/([a-z]+)$ then it does split cat and subcat correctly when visiting .../testing/shop/computer/printen.

What am I doing wrong?

Posted: Tue Jul 04, 2006 10:14 am
by xpgeek
skip
RewriteRule ^shop/([a-z]+)/([a-z]+)/$ index2.php?cat=$1&subcat=$2&rewrite=1%{QUERY_STRING} [L]
try it
RewriteRule ^shop/([a-z]+)/([a-z]+)/?$ index2.php?cat=$1&subcat=$2&rewrite=1%{QUERY_STRING} [L]