I run a site, and let's say on this site I have two pages, page A and page B.
When most people go to foo.html, I want to show them page A. But for a small subset of people I want to show page B instead.
I can implement this in one of two ways:
1. I can make foo.html a php script that checks which group people are in and then open and print page A or B depending on group.
2. I can use .htaccess and mod_rewrite to determine which group they are in and redirect them to the correct page. Even better than that, I can make foo.html == page A, and only redirect for people who need to see page B.
Now, my question is... Which of these is less server intensive? With PHP I have the overhead of loading it as cgi (shared environment, the only way I can do it afaik). I have no idea what the overhead of .htaccess is.
Which way would you choose to implement this? My first impression would be that .htaccess is faster/more efficient, but not knowing the overhead of mod_rewrite much, I thought I would ask. As a note, there are already other mod_rewrite rules in place, if that matters.
My *guess* would be .htaccess. BUT! I'd rather ask the hosting provider to enter mod_rewrite rules to httpd.conf rather than in .htaccess.
Why? Because mod_rewrite works *way* faster when used via httpd.conf.
There's more info about that at apache.org (if you're interested why).