Nginx rewrite url to attain clean url -
I have a site with a URL structure that I'm running on NGNX
Now the number of pages is dynamic and
What would be the exact rule to get a net url,
Along with this, I need to implement a rule, give a negative value to a page, Redirected to the positive value of the number Will.
Right now my current configuration is given below
server {server_name example.com; Error_log /data1/nginx/aggri.com.error.log; Root / data1 / agri; Index index.php; Rewrite_log turned on; Place ~ .php $ {try_files $ uri $ uri / /index.php; Includes fastcgi_params; Fastcgi_pass Unix: /var/run/php5-fpm.sock; 0 expires; Add_header cache-control public; Set $ skip_cache 0; If ($ request_uri ~ * "^ (. * /) Index \ .php $") {return 301 $ 1; }} Place ~ * ^. + (.ogg | ogv | svg | svgz | eot | otf | woff | mp4 | ttf | rss | atp | jpg | jpeg | gif | png | ico | zip | tgz | gz | rar | bz2 | doc | xls | exe | Ppt | rud | mid | midi | wav | bmp | rtf | js | woff | css) $ {access_log off; Log_not_found off; Max Finish; } Location = /robots.txt {access_log off; Log_not_found off; } Place ~ / \. {Deny everything; Access_log off; Log_not_found off; }}
example:
place ~ / Category.php $ {if ($ args ~ ^ page = [-] * ([0-9] +) and query = ([\ w] +) $) {Set $ pg $ 1; Set $ Q $ 2; Rewrite (. *) / $ Q / $ pg /? permanent; }}
Comments
Post a Comment