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 Apache.

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

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

37 questions
1
vote
0 answers

Is it possible to have a regex in the replacement string of a rewrite rule in nginx

I need a quite special rewrite rule but I can’t find the way to do it. I need to map a uri to a regex to a replacement string built with a regex. For example I have a /pdv/plan-AGE44-ABC.pdf uri that could be mapped to the following ones…
1
vote
1 answer

Stop Nginx rewrites breaking all pages following location block

I'm having to rewrite URLs in nginx.conf that contain particular query parameters; As an example:- location /brands/exampleA { if ($arg_cat = "9") { return 301 /page/brand-filter; } if ($arg_cat = "38") { return 301…
zigojacko
  • 1,453
  • 2
  • 12
  • 25
1
vote
0 answers

Using URL's with special characters in nginx maps

When using nginx and maps it is possible to rewrite mutiple URL's with a map file. What is problematic is when the URL contains special characters. I have been breaking my head trying to get this right, and hope this Question / Solution might save…
Adesso
  • 203
  • 1
  • 3
  • 10
1
vote
0 answers

WordPress Date Archives not working in Nginx

WordPress installed in a subdirectory: domain.com/folder WordPress Permalink Settings: domain.com/folder/%postname% Referencing the WordPress Nginx support article, I added the following to my nginx config: location /folder { try_files $uri…
1
vote
1 answer

Rewrite uri to remove www in nginx

I have an unknown number of domains that match a pattern like www.abc123.example.com. Where the number after "abc" is unknown. I thought perhaps I could use a rewrite rule with the regex ~*(www\.abc\w+) Something like: server_name…
LK86
  • 55
  • 1
  • 5
1
vote
2 answers

NGINX 1.13.8 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
  • 25
  • 1
  • 8
1
vote
1 answer

Converting htaccess to Nginx ReWrite (autoconverting not working)

Hi there anyone happens to know Nginx rewrite rules? I'm trying to convert this Apache .htaccess to Nginx Rewrite, I already tried with online converters the homepage and dashboard once logged in work fine but the: news, list, video, music, polls…
0
votes
1 answer

How to redirect all requests except when there's an exact string match

Requirement- I want to redirect all requests that end with /abcd to /products/abcd This should match all urls such as these- /collection/abcd /collections/all/abcd /hello/world/abcd This is what i'm using- rewrite /abcd/?$…
0
votes
1 answer

Nginx Node Proxypass Result to Variable

I want create some rewrite with nginx (5 million links), I read nginx have the option to save it in a map file but need ages to reload + ram usage when I do it this way. My Idea was now User -> Nginx -> Node(which gives the link) -> Save the link in…
StefanBD
  • 101
  • 1
0
votes
1 answer

port RewriteRule from apache to nginx

we have a large php application running on apache now which I would like to migrate to nginx. I’ve got everything to work correctly except for a RewriteRule in a .htaccess file. The web app allows the user to store files which can be publicly…
0
votes
1 answer

PHP script path inconsistencies on nginx with multiple server root paths

I'm struggling a bit with some nginx configuration. Essentially I have one filesystem folder (/remote) that hosts web content at /, but on top of this I want virtual paths /w and /wiki that will host a MediaWiki instance out of a completely…
Malvineous
  • 1,095
  • 11
  • 28
0
votes
2 answers

nginx rewrite : [emerg] unknown "0" variable

1.) Apache Rule: RewriteRule ^(.*)/(.*).htm$ /inner.php?Categories=$0&Title=$1 [L,QSA] 2.) After converting to nginx: rewrite ^/(.*)/(.*).htm$ /inner.php?Categories=$0&Title=$1 break; Question: When user access this page…
0
votes
1 answer

converting htaccess url rewriting rules into nginx

How can i convert my htaccess rules here RewriteRule ^/?([^/]+)/([^/]+)/?$ page-1.php?a=$1&b=$2 [L,QSA] RewriteRule ^/?([^/]+)/([^/]+)/([^/]+)/?$ page-2.php?a=$1&b=$2&c=$3 [L,QSA] into nginx rules? I've tried using converters but i got the…
Axon
  • 3
  • 2
0
votes
1 answer

How do I rewrite these URL's?

I'm working on an ancient (1989!) website which, back in the days, just showed a file directory in some cases. I want to use rewrites to show people a proper file instead. Case: I have 3 folders, 01, 02 & 03. Each of these contains magazine pages,…
Evert
  • 162
  • 1
  • 3
  • 16
0
votes
1 answer

Double rewrite request

I have nginx and I trying create rule in the double condition (if) and double rewrite. The schema is: URL (/direct/file.11223344_aabbcc.js) -> if no file -> [Yes] rewrite to /direct/file_aabbcc.js -> if no (rewrited) file -> [Yes] rewrite to…
Piknik
  • 53
  • 5