views:

57

answers:

1

If say you're utilizing the popular:

RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?$1 [L,QSA]

And you're trying to make your mvc web framework handle 404's, if you don't find a corresponding view for a specified URI would you just manually send 404 http headers within the php application itself, right? Is this how it's done in Zend/Kohana and other frameworks?

Another question, let's say you rewrote an entire site and you want to setup 301s. Would you do that in the place where you configure your routes ( regex style like urls.py in Django ) or in the Virtualhost Directive?

Basically, should I ever have to modify the RewriteRules in the VirtualHost if my web framework is handling the routing?

+1  A: 

On 404's, generally speaking, yes.

As far as doing permanent redirection, I suppose it depends on context. If my routing solution supported doing it in any sane manner, I'd probably go for it unless I expected to run into big scaling problems.

Meaning, if I was handling heavy traffic, and had lots of static stuff content to serve (but not so massive that I was using anything but apache as a web server), I might end up running php under fcgi to keep apache processes thin (and use a better MPM than prefork). In that sort of world, I'd probably end up short-circuiting URLs and have the web server do the redirection.

But even in those sorts of cases, there's no reason not to have done it in your routing framework first.

That way, if a request slips through, things still work, even if they slow down.

timdev