Forum Moderators: phranque
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?
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