Quantcast
Channel: Nginx Forum - Nginx Mailing List - English
Viewing all articles
Browse latest Browse all 7229

What is better location regex or map regex? (1 reply)

$
0
0
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

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Viewing all articles
Browse latest Browse all 7229

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>