What is better location regex or map regex?
Aleksandar Lazic
al-nginx at none.at
Wed Apr 2 11:03:41 UTC 2014
Hi.
I try to transform the pligg htaccess rules to nginx.
https://github.com/Pligg/pligg-cms/blob/master/htaccess.default
There is one from 2010
http://www.edwardawebb.com/web-development/running-pligg-nginx-rewrite-rules
this transformation have some optimization potential, imho ;-).
I would use
location / {
rewrite $uri $dest last;
try_files $uri /index.php;
}
instead of
if (!-e $request_filename){
....
}
and
map $uri $dest {
'~^/advanced-search/?$' '/advancedsearch.php';
'~^/profile/?' '/profile.php';
...
'~^/([^/]+)/?$' '/index.php?category=$1';
'~^/([^/]+)/page/([^/]+)/?$' '/index.php?category=$1&page=$2';
}
or
location ~ ^/advanced-search/?$ {
rewrite ^/advanced-search/?$ /advancedsearch.php last;
}
location ~ ^/profile/? {
rewrite ^/profile/? /profile.php last;
}
...
What is your suggestion for the fastest and smallest solution.
thanks aleks
More information about the nginx
mailing list