php - htaccess file from Apache to Nginx -


i building dynamic site friend , i'm using nginx web server with. site has been designed locally apache , have .htaccess file need convert add in configuration file nginx. .htaccess hide extension of .php pages , give error if call page extension. here .htaccess file

rewriteengine on  rewritecond %{request_filename} !\.php$  rewritecond %{request_filename} -f [or] rewritecond %{request_filename} -d rewriterule . - [l]  rewritecond %{request_uri} !\.php rewritecond %{request_filename}\.php -f rewriterule ^(.*)$ $1.php [l]  rewritecond %{env:redirect_status} ^$ rewritecond %{request_uri} \.php rewritecond %{request_filename} !index.php$ rewritecond %{request_filename} !404.php$  rewriterule ([a-za-z0-9\-_]*) 404.php [l] 

here configuration file nginx

server { listen 80 default_server; listen [::]:80 default_server ipv6only=on;  root /var/www/html; index index.php index.html index.htm;  server_name my_server_ip_is_here;  location / { try_files $uri $uri/ = /error/404.html; }  location ~ \.php$ { try_files $uri /index.php =404; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param script_filename       $document_root$fastcgi_script_nam$ include fastcgi_params; } location / {  rewrite ^(.*)$ /$1.php break; if ($request_uri ~ "\.php"){ rewrite ([a-za-z0-9\-_]*) /404.php break;                            }  } } 


Comments