my old server had this in the htaccess file:
< FilesMatch “^resort$”>
ForceType application/x-httpd-php
< /FilesMatch>
where I had a resort php file (without the php extension)…
so the file was domain.com/resort/param1/param2
I’m struggling to make the equivalent work for nginx…
i’ve tried these items, but none work:
location = /resort/ {
-
try_files $uri /resort.php;
-
try_files $uri $uri/ @extensionless-php;
-
try_files $uri $uri/ $uri.html $uri.php?$query_string;
-
try_files $uri $uri/ /resort.php$is_args$args;
-
rewrite ^(.*)$ /resort.php last;
}
So how do I execute the resort file as php, when this url is in the browser:
domain.com/resort/param1/param2.php
THANKS!
PS. would love some pages/resources/tutorials that explain “apache to nginx” for people who don’t understand nginx 🙂
i’ve been to nginx site, but IMO, I need to know more than I do to figure it out or understand what the nginx site is saying.
update:
i think this is close, but still not working 🙁
this is url: domain.com/resort/city/state.php
here is directive:
location ~ /resort/ {
rewrite ^/resort/(.*)/(.*) /resort/$1/$2 break;
}
2
Answers
this is what worked for me:
To execute a file without a
.php
extension as though it was a PHP file, you will need to replicate thelocation
block that handles those types of request.It will look something like this:
To process the URI
/resort/param1/param2
using the PHP file located at/resort
, you might use something like:See this document for
location
syntax.