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
0answers
21 views

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

Exclude google doc embed iframe from nginx rewrite rule?

I hope that someone can help me here as I have very limited knowledge about server related stuff. I have a WordPress site where I want to limit the /wp-content/uploads/ directory access to logged in ...
1
vote
0answers
21 views

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 ...
2
votes
1answer
75 views

Apache .htaccess to NGINX RewriteRules Port

So, I am actually trying to port the RewriteRules from Apache to NGINX but it seems I am not able to completely port out. Actually, on my server I do have a running site on https://example.com domain ...
0
votes
0answers
34 views

Indexing static folder from multiple subdirectories in nginx along with geo redirection

I am building a static site where the user will see a different index.html file based on their country. My plan is to use GeoIp module in nginx where, if a person from country 1 visits my domain www....
1
vote
1answer
47 views

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 ~*(...
1
vote
2answers
222 views

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 ...
0
votes
2answers
129 views

Rewrite image request to sub-directory structure in Nginx

Given a location like this: location ~ ^/user-content/img/) { root /srv/foo/bar/uploads/; autoindex off; access_log off; expires 30d; } Is it possible using nginx to have a request for /user-...
0
votes
0answers
21 views

Need help on nginx url rewriting

I'm having trouble rewriting this URL below: https://domain-name.com/2020/10/title_of_article.html?id=1 into: https://domain-name.com/0/1 the year is unnecessary so it is removed/truncated/ignored ...
0
votes
2answers
773 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
137 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
722 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
210 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 ...
1
vote
2answers
996 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
1k 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
1k 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
612 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
562 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
528 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
522 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
69 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
88 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
273 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
701 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
459 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; ...
2
votes
2answers
700 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
17k 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
100 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
34 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
5k 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
46 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
396 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 ...