Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Re: Nginx rewrite not working as expected

$
0
0
I have added whole conf below and URI is http://192.168.112.132/sess1234/wordpress
In log I'm getting "/a$handler/b$realURI"; why variable are empty not sure may be regex not match
/usr/local/nginx1/a_session/b/wordpress > GET /sess1234/wordpress HTTP/1.1



```
user root;
worker_processes 1;
error_log logs/error_debug.log debug;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;

client_max_body_size 2000M;
log_format scripts '$document_root$fastcgi_script_name > $request';
access_log logs/error.log scripts;

map $realURI $handler {
"~*/sess.*[.]php$" "_php";
"~*/sess.*[.](jpg,gif,png,svg)$" "_images";
"~*/sess.*$" "_static";
default "_session";
}

server {
listen 80;
server_name localhost;
root /usr/local/nginx1;
index index.php index.html;

location ~ "^/(?<sessionID>sess[a-z0-9]+)(?<realURI>.*)$" {
rewrite "^.*$" "/a$handler/b$realURI";
}

location /_php {
internal;
include fastcgi.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}



error_page 500 502 503 504 /50x.html;

location = /50x.html {



root html;

}

}

}
```

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>