Forum Moderators: phranque
this is my firts post so a big thank you before I start to anyone willing to help
I am new to mod_rewrite
I have racked my head for days as to why my code wont work...
eureka I have found out why it wont work
now I need a solution
I have a list box with categories in and when the user clicks that it posts back to the same page with the category selection
then lists the first 4 found with a more>> link
the more link is the problem
for example when the user has chosen "All Categories" the url has a space in
the old link would say
<a href="index.php?mode=beinggreen&list=yes&cat=<? echo $cat; ?>&count=<? echo $page; ?>&$keyword=<? echo $keyword; ?>">more ></a>
and the url would replace the spaces with %20
the new mod_rewrite code
<a href="index/beinggreen/yes/<? echo $cat; ?>/<? echo $page; ?>/<? echo $keyword; ?>">more ></a>
my mod_rewrite code
RewriteRule ^index/([a-z]+)/([a-z]+)/([a-z]+)/([A-Za-z0-9-]+)/([a-z]+)/?$ index.php?mode=$1&list=$2&cat=$3&count=$4&keyword=$5
I know I can get round this by doing a $cat=str_replace(" ","",$cat); and then on reloading the page doing a switch statement replacing the space but the categories come from a db table so when I add a new category I would have to strip the spaces out and add another field and the reference it everytime I reload the page.
So,
is there an easy way around this in mod_rewrite that can solve this problem
Sorry if this post is a bit long winded
many thanks again for any help
I don't do anything with the mode_rewrite
line before the link, I str_replace the space for a hyphen
and then on page reload, I str_replace hyphen for space
must remember this when adding new categories...no hyphens