htaccess Elite

.htaccess tutorial


All times are UTC [ DST ]





Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Need some help with REWRITE Condition
PostPosted: 27 Feb 2007 16:13 
Offline

Joined: 27 Feb 2007 15:57
Posts: 1
Location: Chicago, IL
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://www.mydomain.com/folder/index.php?1catid=60453


But what I want is urls that look like:

Code:
http://www.mydomain.com/folder/foods-groceries/


Since I know the titles of all the categories I figure I can use a condition to pretty much match up to whatever category # is displayed and display and SEO friendly url like above.

If I had an example of how I would rewrite those categories to my .htacces I could complete the thing myself. I just don't understand how I am to rewrite it.

Please help!

So to summarize: if index.php?catid=1065, then display /food-grocery
or if index.php?cat=10000 then display /chicken

Thanks so much!

Jori



AEP Design - Design and Internet Marketing Solutions
Make Money the Easy Way


Top
 Profile  
 
 Post subject: Re: Need some help with REWRITE Condition
PostPosted: 28 Feb 2007 04:27 
Offline
User avatar

Joined: 25 Sep 2006 04:48
Posts: 242
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];

?>


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: MSNbot Media and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB