Answer the question
In order to leave comments, you need to log in
Setting up rewrite in Nginx?
Today I switched to Nginx from Apache, and faced with the need to configure rewrite, or rather transfer mod_rewrite .htaccess to nginx.
Here is my config in .htaccess:
AddDefaultCharset UTF-8
php_flag magic_quotes_gpc Off
php_flag magic_quotes_runtime Off
php_flag register_globals Off
Options -Indexes
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/favicon.ico
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?route=$1 [L,QSA]
charset utf-8;
location = /favicon.ico {
}
autoindex off;
location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.php?route=$1 break;
}
}
Answer the question
In order to leave comments, you need to log in
Try like this
charset utf-8;
autoindex off;
location / {
try_files $uri $uri/ /index.php?route=$request_uri;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question