Forum Moderators: phranque

Message Too Old, No Replies

Many rules for one file

3 rules for one work

         

mubasharw

8:58 am on Feb 21, 2007 (gmt 0)

10+ Year Member



Hi,
I have a b2b portal and there is file named ‘a0001.php’ which shows me sell leads in all listed categories plus the option to navigate into a specific category say Agriculture->Beans->(listing of beans), so I have 3 options to access a0001.php
1) [DomainName.com...]
2) [DomainName.com...] (to access listings of agriculture, agriculture =1)
3) [DomainName.com...] (to access listings of Beans, Beans =11)

Now using .htaccess I want to access a0001.php file by using the url
1)http://www.DomainName.com/sell_leads/ (to display all listings of all categories)
2)http://www.DomainName.com/sell_leads/agriculture/ (to display all listings of agriculture)
3)http://www.DomainName.com/sell_leads/agriculture/beans/ (to display all listings of beans)

And currently I have following code (3 lines for above 3)

RewriteRule ^ sell_seads /$ a0001.php [NC]
RewriteRule ^ sell_seads /(.*)/(.*)/$ a0001.php?cid=$1 [NC]
RewriteRule ^sell_seads/(.*)/(.*)/(.*)/$ a0001.php?cid=$1 [NC]

(Here first (.*) is giving me the category ID which I required for further work)

Please let me know is it appropriate to define 3 rules (3 lines) for 3 types of work with a single file, as I have now 15 such files and following the above I have to write there 15*3=45 rules / lines..?

Thanks,
Mubashar

jdMorgan

2:37 pm on Feb 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd suggest the following changes:

RewriteRule ^sell_seads/$ a0001.php [L]
RewriteRule ^sell_seads/([^/]+)/([^/]+)/$ a0001.php?cid=$1 [L]
RewriteRule ^sell_seads/([^/]+)/([^/]+)/([^/]+)/$ a0001.php?cid=$1 [L]

This is an execution efficiency improvement only; The rest of the answer depends on what the other 14 files and their rewritten script calls look like.

Jim