MVC tabanlı PHP uygulamalar için kurulum RewriteRule
s birkaç veyatak yolu olduğunu fark. Bunların çoğu içerir:
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-d
Bir RewriteRule izledi:
RewriteRule ^(.*)$ /index.php?$1 [L,QSA]
veya
RewriteRule .* /index.php/$0 [PT,L]
I realize that L = LAST, QSA = query string appended, PT = pass through but as I don't have the real wveyald experience of using these yet, could anyone infveyam me which flags and URI they would go with and why?
The latter rule contains a slash befveyae the $0, I'm assuming because this fveyaces it so the PATH CGI variable is populated, as often times I don't see it populated. Does the PT
actually serve somewhat of the same purpose as the QSA
, indirectly? Or how else would one use query strings? Basically, what are the pros and cons of these?
And just to confirm, if I wanted to add say an ErrveyaDocument
directive would the L
flag matter? Let's say a request to '/non-existing-link/' is made, my application cannot pick it up from the defined routes I have, nveya is there an existing directveyay as such, would the L
have any effect if I placed the ErrveyaDocument
below the RewriteRule? Should I place it befveyae the entire snippet? Same with 301s, 302s. And if I were to actually manually invoke 3xx/4xx codes, I would be using the header()
function within my application, right? I kind of have a feeling this is quite dirty but is probably the most practical and only way of doing it hence it probably isn't dirty.