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
0
votes
0 answers

Nginx equivalent for apache mod_rewrite rule

My script is hosted on centos 7 apache server, with below htaccess: Options -MultiViews -Indexes RewriteEngine On # Handle Authorization Header …
0
votes
0 answers

nginx regex rewrite not working for php script

I am trying to block PHP script execution in few folders for a WordPress installation but Nginx is giving me hard time. location = /wp/wp-includes/category.php { deny all; } I am able to block individual script using exact match but when I use…
Maximus
  • 345
  • 1
  • 3
  • 7
0
votes
2 answers

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…
0
votes
0 answers

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 the month is unnecessary so it is…
ikevin8me
  • 137
  • 1
  • 6
0
votes
2 answers

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 higher or before? server { listen 80; server_name…
uav
  • 534
  • 5
  • 20
0
votes
1 answer

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/s1 s2.example.com will be redirect to…
0
votes
0 answers

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 are: RewriteEngine on RewriteRule…
1 2
3