I've got a Nginx Web Server Setup with PHP and I want to move on Nginx and I want to convert these .htaccess rules to nginx.conf file:
RewriteRule ^blog(|/)$ /data/core/site/blog.php
RewriteRule ^blog/post(|/)$ /data/core/site/blogpost.php
So far this is what I have:
location /blog {
rewrite ^(.*)$ /data/core/blog.php last;
}
However if I visit the page (http://example.com/blog), It gives me the file to download, I want it to server the PHP and display content, how would I fix this?
Full Nginx configuration: (Using Winginx Package on Windows):
server {
listen 127.0.0.1:80;
server_name localhost;
root home/localhost/public_html;
index index.php;
log_not_found off;
#access_log logs/localhost-access.log;
charset utf-8;
location ~ /\. { deny all; }
location = /favicon.ico { }
location = /robots.txt { }
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9054;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include fastcgi_params;
}
location /blog {
rewrite ^(.*)$ /data/core/blog.php last;
}
}