Forum Moderators: phranque
Will write: domain/color-purple-flowers.html.
Not a problem. I can also use this for my products page such as: domain/products-prodID.html
But I also have hundreds of inner pages made up of categories and than sub-categories.
domain/fruits-red-cherries
domain/fruits-blue-blueberries
and than........
domain/vegetables-green-peas
domain/vegeatables-yellow-corn
and so on.........
I basically have about 25 categories and about 12 sub-categories in each. I obviously can't have 300 seperate re-write rules for each one.
Each page uses the variable "$thisPage" such as:
$thisPage="fruits-red.php"
$thisPage="fruits-blue.php" etc..
I was hoping I could somehow use my php variable to create the re-write on the fly but I don't think that's possible. Probably because it looks at the .htaccess first and has no idea what the page is anyway?
The only other thing I can think of would be to create a directory for each category and than place an .htaccess in each directory folder with a re-write for each sub-directory. So I would have abot 12 rules and 25 seperate .htaccess files. That would give me:
domain/fruits/red-cherries
domain/vegetables/green-peas etc.....
Would that be the way to go or is that also too much?
I hope this makes sense, my brain is about fried!
I'm counting on you for this JD :)
You could put an .htaccess file in each subdirectory. This has the benefit of execution efficiency, but makes modifications and maintenance more difficult.
But you could also likely come up with a minimal set of just a few rules to handle your 300 URLs, using multiple variables in each rule. How you would do this depends on precisely how you want to map URL-strings to script calls and query string name/value pairs, and on how consistent you've been in naming/mapping these URL-string-to-script calls. The single-variable example you provided isn't sufficient to discuss this further, though.
BTW, you can make your existing rule much more efficient:
RewriteRule ^color-purpl[b]e-([^.]+)\.h[/b]tml$ /color-purple.php?search_fd1=$1 [L]
Jim