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

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
nutkenz
Forum Contributor
Posts: 155
Joined: Tue Jul 19, 2005 12:25 pm

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

Post 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?
User avatar
xpgeek
Forum Contributor
Posts: 146
Joined: Mon May 22, 2006 1:45 am
Location: Kyiv, Ukraine
Contact:

Post 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]
Post Reply