I need a help to configure my website on nginx server. Earlier i was using apache so there i was using htaccess to redirect on index.php. But i just got to know that nginx don't support htaccess. I am new in nginx server. Let me make it more clear with example.
When i was using apache then my htaccess was like below-
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L]
</IfModule>
I need to do the same thing in nginx server now. Please anyone suggest me how i can do this. I tried to figure it out myself and tried many thing but nothing works eg-
I tried this-
location / {
# Check if a file or directory index file exists, else route it to index.php.
try_files $uri $uri/ /index.php;
}
I also tried the solution suggest here: How to enable URL rewrite in Ubuntu, nGinx and codeigniter?
location ~* \.php$ {
fastcgi_pass unix:/run/php/php5.6-fpm.sock;
root /var/www/html/;
try_files $uri =404;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 4k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
}
My requirement is to rewrite all these urls :
https://example.com/xyz
https://example.com/abc
https://example.com/pqr
To
https://example.com/index.php
My Folder Structure- folder-structer.png
Thanks in advance.