URL Rewrite rule not working on nginx -
i want make url rewrite in apache within nginx. give location based request more url friendly look. keep getting 404 page not found.
server { # site definitions (...) # fastcgi defitions (...) location / { # code make wp super cache work (...) rewrite ^/ads/category/(.*)/(.*)$ /ads/category/$1?location=$2 permanent; rewrite ^/category/(.*)/(.*)$ /ads/category/$1?location=$2 last; rewrite ^/category/(.*)$ /ads/category/$1 last; } }
i'm putting above code within virtual host definition /etc/nginx/sites-enable/mysite. far dont know real method debug going on.
instead of defining rewrite rules in single location / {} block; try this:
# site definitions (...) location / { # code make wp super cache work (...) # remove following line if have index @ site definitions.. index index.php; try_files $uri $uri/ /index.php?$args; } if (!-f $request_filename) { rewrite ^/ads/category/(.*)/(.*)$ /ads/category/$1?location=$2 permanent; rewrite ^/category/(.*)/(.*)$ /ads/category/$1?location=$2 break; rewrite ^/category/(.*)$ /ads/category/$1 break; } # fastcgi defitions (...)
i know if evil in nginx world problematic when used in location {} block similar configuration working charm on virtual server.
Comments
Post a Comment