Forum Moderators: phranque

Message Too Old, No Replies

Internally rewrite problem

         

crosescu

2:36 am on Nov 2, 2006 (gmt 0)

10+ Year Member



Hi,

I have two rewrite rules that I am struggling with.

RewriteRule ^categories/browse/([^/]+)/([^/]+)/(feed¦rdf¦rss¦rss2¦atom)/?$ /index.php?cat_name=$1&subcat_name=$2&feed=$3 [QSA,L]

RewriteRule ^categories/([^\ ]*)/?$ /view_category.php?cat_name=$1 [QSA,L]

the problem is that when a url like "categories/browse/food/dogfood/blah" is entered the second rule is matched and I dont want that. it should generate a 404 error.

Much Regards,
Chris

jdMorgan

2:44 am on Nov 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Why are you using a space to end this match in the second rule?
([^\ ]*)/?
With this pattern, the contents of $1 will contain *any and all* characters following "categories/" except for a final slash unless there is a literal space in the URL-path. If you want to stop on the next "/" after" categories/", then put a slash instead of an escaped space in the negative-match group -- like in your first rule.

For more information, see the regular-expressions tutorial cited in our forum charter [webmasterworld.com].

Jim