allstar784 wrote:
I understand how to place the or, however here is my situation. I have several categories over 500 that are dynamically set so the url looks similar to
Code:
http://x.com/folder/index.php?1catid=60453
But what I want is urls that look like:
Code:
http://x.com/folder/foods-groceries/
So to summarize: if index.php?catid=1065, then display /food-grocery
or if index.php?cat=10000 then display /chicken
Try this allstar784,
Code:
RewriteEngine On
RewriteBase /
RewriteRule ^folder/foods-groceries/$ /folder/index.php?catid=1065 [NC,L]
RewriteRule ^folder/chicken/$ /folder/index.php?catid=10000 [NC,L]
That means that when a visitor to your site goes to the url
http://x.com/folder/foods-groceries/ they will really be seeing whatever /folder/index.php?catid=1065 returns.
Likewise
http://x.com/folder/chicken/ --> /folder/index.php?catid=10000
If you have more than 100 categories than you should use php as the main workhorse.. First you would redirect every url that is in the /folder/ that is a directory /anything/ to your /folder/index.php script.
Code:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/index.php.*$
RewriteRule ^folder/([^/]+)/$ /folder/index.php?cat=$1 [NC,QSA,L]
Then in index.php you would do something like this.
Code:
<?php
$Category_Name = $_GET['cat'];
$Category_Array = array(
'foods-groceries' => '1065',
'chicken' => '10000'
);
$Category_ID = $Category_Array[$Category_Name];
?>