Forum Moderators: phranque

Message Too Old, No Replies

Mod Rewrite Help

         

unni

9:31 am on Jul 21, 2006 (gmt 0)

10+ Year Member



When i created my .htaccess file some times back i was new to mod rewrite so i created like this to catch my categories and subcategories.

RewriteRule ^([^/]+)/$ /cat.php?cat=$1 [L]
RewriteRule ^([^/]+)/([^/]+)/$ /subcat.php?cat=$1&subcat=$2 [L]

It was working fine but the problem was whatever the user types the php file takes it instead of generating 404. I dont want to change the URL structure so I changed it in this way.

RewriteRule ^(cat1¦cat2¦cat3¦....cat14)/?$ /cat.php?cat=$1 [L]
RewriteRule ^(cat1¦cat2¦cat3¦....cat14)/([^/]+)/?$ /subcat.php?cat=$1&subcat=$2 [L]

This is working fine. But will it create any problem or affect the server performance since i am listing 14 categories?

Is there any other solution?

jdMorgan

1:11 pm on Jul 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Theoretically, yes, it could cause some server performance problems once you start getting 100,000 unique visitors a day or so... Then you might notice a slight server slow-down.

Until then, maybe it'll slow your server down a tiny bit, but then again, so does using php to generate pages instead of serving static HTML documents... :)

I wouldn't worry about it until you actually notice server performance problems. At that point, it becomes just one of many factors you might want to look at from an optimization standpoint.

The simplest way to optimize this kind of rewrite would be to re-organize your site, and put all php-generated content in one directory-path, and all static content into other paths. Then, all the RewriteRule has to do is to check the top-level directory path element in order to decide whether to rewrite the request or not. So that would be faster, but would likely require you to change the URLs on existing resources... and that in itself is not a good thing to do.

Jim

unni

5:35 pm on Jul 22, 2006 (gmt 0)

10+ Year Member



Thanks Jim

I dont even dream about 100,000 unique visitors a day :)

Eventhough this site is with 15,000 records i am getting only 1000 visitors per day.. i am trying different options to bring it to atleast 5000. So for time being this code will do.

Unni