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)

Filter by
Sorted by
Tagged with
0
votes
2answers
68 views

Nginx rewrite/return phase order

I know there are Nginx phases. Why does the following snippet deliver the "200 Host: example.com" instead of forwarding to Google? What would be a generally valid workaround to evaluate Lua ...
1
vote
1answer
68 views

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 ...
0
votes
1answer
73 views

Nginx redirect to main domain from subdomain without changing URL in address bar

I have a domain and wildcard subdomains. main domain: example.com subdomains: s1.example.com, s2.example.com etc. Now the requirements is s1.example.com will be redirect to example.com/organization/...
0
votes
0answers
31 views

How to count the number PDF downloads using PHP on an NGINX server - conversion of Apache Rewrite Rule

I found excellent rewrite rules and a PHP script that works with Apache to count the number of downloads for certain file types. I need this converted to be NGINX friendly. The Apache rewrite rules ...
0
votes
0answers
27 views

nginx Subdirectory config to work JS (apache work good, nginx HELP)

I have a some site with work on JS library and path to JS files need to start with ./ (like ./js/somescript.js or ../js/somescript.js) and URL of pages like mydomain.com/lk/welcome but I need make ...
1
vote
2answers
244 views

How to Nginx rewrite to get clean url of page numbers

Recently we have moved to Nginx from Apache, Under apache it used to be very easy just put some stuff on .htaccess and done. RewriteEngine on RewriteBase / # only rewrite if the requested file doesn'...
1
vote
2answers
422 views

How to convert this very simple .htaccess to Nginx?

I'm using this .htaccess that pass everything after URL to $param, so example.com/news/id goes to PHP as $_GET['param']='news/id'. But Nginx is always throwing me to 404 page. My .htaccess: ...
1
vote
0answers
614 views

How to filter urls with sub_filter with nginx

I recently was given the task of setting up a proxy and everything works great now, except that I can't seem to filter basic urls with sub_filter. This code works flawlessly sub_filter 'anna' 'bob'; ...
0
votes
1answer
389 views

nginx rewrite based on part of URL

I'm trying to set up nginx rewrites; I have it successfully set up to remove the extension: https://example.com/accounts?id=user-123 points to https://example.com/accounts.php?id=user-123 using just ...
1
vote
0answers
325 views

Nginx: how to rewrite HTTP_HOST keeping the original URL unchanged

A bit of background: When abc.mywebsite.com (or xyz.mywebsite.com and so on) is requested, it received by haproxy, which replaces the Host header with main.company.net and also adds the X-Custom-...
1
vote
2answers
391 views

Nginx caching reverse proxy with URL rewrite

I am serving large static files from a backend storage server with slow spinning disks. This server is hidden behind fast nginx reverse proxy with local cache on SSD. It works great and fast. Now I ...
0
votes
1answer
382 views

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'...
0
votes
1answer
65 views

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 -> ...
0
votes
1answer
83 views

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 ...
0
votes
1answer
228 views

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 ...
1
vote
0answers
463 views

nginx rewrite error, invalid number of arguments

I'm running nginx 1.13.6. The configuration has this directive to serve a virtual host service.company.com/ using service.company.com/svc/: if ($server_name = service.company.com) { rewrite ^(.*)$ ...
0
votes
2answers
395 views

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; ...
1
vote
2answers
633 views

Finish processing rewrite directives in location and return 301

I have the following in my nginx.conf: location ~* /collections.*?products/([^/]+)/?$ { rewrite ^/collections.*?products/([^/]+)/?$ /$1.html; rewrite ^([^_]*)_([^_]*)_(.*)$ $1-$2-$3; ...
1
vote
2answers
12k views

nginx reverse proxy with query parameter modification

I have an application that is not SSL aware behind nginx, thus I need to do the following http://example.com/f1/f2/page?next_page=http%3A//example.com/f3/new_page has to change to https://example....
0
votes
1answer
98 views

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 ...
0
votes
1answer
33 views

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, ...
1
vote
1answer
3k views

rewrite or internal redirection cycle while internally redirecting to, in nginx

I'm trying to get a rewrite rule to work for nginx and Wordpress. After a reboot of nginx, I try the site and get an IS 500 error page. The log file says: *1 rewrite or internal redirection cycle ...
1
vote
1answer
43 views

Ngnix static site with one PHP alias/rewrite

I have a static site Angular site and I want to have the path /deploy run a php the php script /var/www/app/deploy/deploy.php. I have tried a rewrite rule and having no luck. What is the proper way ...
0
votes
1answer
323 views

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 -> ...
1
vote
1answer
1k views

add a URL suffix path (for mobile AMP) without causing a redirect loop in nginx

i am using nginx web server for my wordpress website. i am going to make it to become amp version for mobile serve. i wanna add /amp/ to my url. i also using pretty permalink for my current url,so ...