Questions tagged [ngx-http-rewrite-module]

nginx rewrite module is a default module that implements if-statements, rewrite directives and allows URL manipulation in nginx with the help of PCRE regular expressions (it's what mod_rewrite is to Apache)

The ngx_http_rewrite_module module of is used to change request URI using PCRE , return redirects, and conditionally select configurations.

(It is similar in its concept to of .)

http://nginx.org/docs/http/ngx_http_rewrite_module.html

http://ngx.su/src/http/modules/ngx_http_rewrite_module.c

16 questions
3
votes
1 answer

Configure Nginx to ignore a path in url

My website is at /root/website/, in it there is a folder static for static files, when the user visit: /static/dfd99a5/xxx.js, I wish to serve /root/website/static/xxx.js, how can I do this in nginx?
3
votes
1 answer

How to conditionally override a header in nginx only if a cookie exist?

Is there a way to check if a specific cookie exist in nginx? For now I have a section like below to set header from cookie: proxy_set_header x-client-id $cookie_header_x_client_id; I want to check if that cookie exist then set the header,…
Alireza
  • 6,497
  • 13
  • 59
  • 132
3
votes
1 answer

Remove index.php from Joomla! URLs with NGINX

How do I remove index.php from my Joomla URLs? For example: http://domain.com/index.php/webpage should become http://domain.com/webpage I've been following some guides that I've found but it all result in a redirect loop, 404 or internal server…
2
votes
1 answer

Nginx: how do I rewrite a URL subdirectory to a query parameter?

I am trying to rewrite a URL in a WordPress website running Nginx so that the last subdirectory is transformed into GET-parameter: http://mydomain/property/aid/1234/ to http://mydomain/property/?aid=1234/ I tried with add_rewrite_rule in WordPress,…
Chris Chen
  • 23
  • 5
2
votes
1 answer

Match and redirect "http://" (double slash) from URI path with Nginx

When I enter the request URL http://mydomain/url=http://example.com, I want Nginx to return http://example.com, but instead it gives me http:/example.com (one slash is removed). What’s wrong? This is my Nginx conf: location ~ url=(.*)$ { return…
Brock Chen
  • 23
  • 2
2
votes
1 answer

Nginx Block User-Agent "-"

I'm getting some kind of access that is causing problems on my server: 172.68.28.210 - - [03/Jul/2016:13:41:06 -0300] " "GET / HTTP/1.1" 502 166 "-" "-" I would like to block even the $HTTP_USER_AGENT, made this attempt did not work. if…
2
votes
3 answers

Redirect with nginx (remove substring from url)

I want do a redirect from old url: http://example.org/xxxxxxxxx.html To new urls (remove ".html") http://example.org/xxxxxxxxx How I can do this with nginx? EDIT: xxxxxxxxx can be differ, example: http://example.org/url-1.html redirect to…
rpayanm
  • 6,303
  • 7
  • 26
  • 39
1
vote
0 answers

Ngnix rewrite won't behave as expected

I am trying to rewrite my urls from http://localhost/?search=QUERY&ingrids=&_ingrids=&page=1 to http://localhost/QUERY/index.html I did manage to create a rule that rewrites the url, but it seems to redirect it instead of rewriting it. I read about…
1
vote
2 answers

How to redirect subpaths in nginx with nginx rewrite module?

I have a set of url paths which having changed in my application, e.g.: /dataview/unknownvvvo/ => /backend/unknown-vvvo /dataview/servicecounter => /backend/servicecounter-events I try to address this with rewrite rules in nginx: user app…
1
vote
2 answers

Redirect vBulletin URLs to XenForo with NGINX rewrite rules

I would like to know how to rewrite the nginx this url: Old URL: http://www.webcheats.com.br/vbulletin/showthread.php?t=2175433 New URL: http://www.webcheats.com.br/threads/2175433/ thanks
1
vote
2 answers

Nginx redirect/rewrite vBulletin URLs (with slug) to XenForo

Nginx redirect/rewrite Rule How to make the configuration of nginx for redirection: Old Url http://www.webcheats.com.br/forum/elsword-downloads-de-cheats-utilitarios/2369461-26-04-revolution-trainer-elsword.html /forum/ - It is the folder that…
0
votes
1 answer

NGINX Rewrite url not works

I have following location with rewrite: location ~ ^/payment/gateway/v2/order/complete/(.*)$ { proxy_pass http://api.test.com:8080/payment/gateway/v2/order/complete?order_id=$1; } then I tried this: location /payment/gateway/v2/order/complete…
SBotirov
  • 13,872
  • 7
  • 59
  • 81
0
votes
3 answers

Proxy_pass ignoring port

I have a CentOS server running NGINX listening to 80 and a DB servering an app on 8080. I want to be able to Type http://example.com/dev/abc and have it actually access http://example.com:8080/apex/abc or http://localhost:8080/apex/abc I have…
0
votes
1 answer

Joomla SEF URLs with Nginx

Gentoo Linux 4.4.8-hardened Nginx 1.10.1 MySQL 5.6.33 PHP 5.6.26 Joomla 1.5.26 Migration to latest Joomla is close to impossible because of the amount of custom components that have been written during 5 years. The problem is with URLs. Although we…
0
votes
2 answers

Nginx 301 redirect syntax error

I just found that my nginx syntax was not correct: location /news { rewrite ^(.*)$ /blog redirect;} I want to redirect mysite.com/news to mysite.com/blog but that code was redirecting more pages to blog. Anyone can help me explaining the error and…
1
2