I want to redirect all dynamic request to index.php
for example my index.php
:
<?php
echo "hi";
?>
here is my nginx configure of php:
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass 127.0.0.1:9000;
}
when i add configure with try_files
:
location / {
try_files $uri $uri/ /index.php =404;
}
it just return raw text
<?php echo "hi"; ?>
and i modify the nginx configure with rewrite
it will return hi
properly :
location / {
rewrite ^(.*) /index.php last ;
}
Question
What's different between try_files
and rewrite
?
Why the directive try_files
do not work as i want ?