Link to home
Start Free TrialLog in
Avatar of Bob-Villa
Bob-Villa

asked on

Mod Rewrite Regex Syntax

Here's a sample of some code from my .htaccess file

RewriteRule ^TMP/Cat(.*)/(.*)$ /TMP/run.php?r=cat$1&c1=$2

How can I get this to return valid if the user types a url with ot without a trailing slash?
with my above example  /TMP/Cat1/2  works but  /TMP/Cat1/2/  does not
----------------------------------------------------------------------------------------------------

RewriteRule ^TMP/Cat(.*)/(.*)/(.*)/(.*)$ /TMP/run.php?r=cat$1&c1=$2&c2=$3&o=$4
RewriteRule ^TMP/Cat(.*)/(.*)/(.*)$ /TMP/run.php?r=cat$1&c1=$2&o=$3
RewriteRule ^TMP/Cat(.*)/(.*)$ /TMP/run.php?r=cat$1&c1=$2

Anyway to consolidate this?

I don't want to have to add filler to my URLS.

i.e.  I want the following urls to work with one entry in my htaccess file if that is possible: (keep in mind my first question)

/TMP/Cat1/2
/TMP/Cat1/2/3
/TMP/Cat1/2/3/4

I don't want to have to write a url like this:

/TMP/Cat1/2/0/0  then have my script ignore the zeros as a workaround




ASKER CERTIFIED SOLUTION
Avatar of caterham_www
caterham_www
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial