Hi, i want a single php script to handle all incoming requests to my /blog directoy. The php script checks wether a SQL record exists for the url (i.e. www.example.com/blog/example_article). If a record is found it serves the corresponding page data. If there is no record for a url (i.e. www.example.com/blog/nothing_here) it redirects to 404.
I need a rewrite rule in nginx for that.
My current config:
root /usr/share/nginx/html/example/;
index index.php;
server_name example.com www.example.com;
location / {
try_files $uri $uri/ @extensionless-php;
}
location /blog {
rewrite ?; // here i need a rewrite rule
}
location /uploads {
deny all;
}
error_page 404 /templates/404.php;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
fastcgi_intercept_errors on;
}
location @extensionless-php {
rewrite ^(.*)$ $1.php last;
}
Please note that i am using extensionless URL's.
I need a rewrite rule in nginx for that.
My current config:
root /usr/share/nginx/html/example/;
index index.php;
server_name example.com www.example.com;
location / {
try_files $uri $uri/ @extensionless-php;
}
location /blog {
rewrite ?; // here i need a rewrite rule
}
location /uploads {
deny all;
}
error_page 404 /templates/404.php;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
fastcgi_intercept_errors on;
}
location @extensionless-php {
rewrite ^(.*)$ $1.php last;
}
Please note that i am using extensionless URL's.