I am building a website based on angularjs and nginx server.I am struggling at url rewrite for angularjs , I used my development environment as apache which is working well.I want to use extensionless php so that if i visit www.mywebsite.com/register it points to www.mywebsite.com/register.php . When I put slash near www.mywebsite.com/register/it is not working.For angular I want the url as www.mywebsite.com/register/step2 to www.mywebsite.com/register/#!/step2
server {
server_name mywebsite.com;
return 301 $scheme://www.mywebsite.com$request_uri;
}
server {
listen 80;
server_name localhost www.mywebsite.com;
#charset koi8-r;
#access_log /var/log/nginx/log/india.access.log main;
location / {
root /var/www/mywebsite;
index index.php index.html index.htm;
}
location ~ /register/ {
rewrite ^ register.php/#/$1 redirect;
break;
}
error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/mywebsite;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location /api/ {
try_files $uri $uri /api/index.php?$query_string;
}
location ~ \.php$ {
if ($request_uri ~ ^/([^?]*)\.php($|\?)) { return 302 /$1?$args; }
root html;
#include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/mywebsite$fastcgi_script_name;
include fastcgi_params;
fastcgi_intercept_errors on;
error_page 404 /404;
}
location @extensionless-php {
rewrite ^(.*)$ $1.php last;
}
# if enable status in PHP-FPM config
location ~ ^/(status|ping)$ {
allow 127.0.0.1;
#deny all;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
}