ngx-http-rewrite-module

Redirect with nginx (remove substring from url)

半世苍凉 提交于 2021-01-27 19:11:25
问题 I want do a redirect from old url: http://example.org/xxxxxxxxx.html To new urls (remove ".html") http://example.org/xxxxxxxxx How I can do this with nginx? EDIT : xxxxxxxxx can be differ, example: http://example.org/url-1.html redirect to http://example.org/url-1 http://example.org/another-url.html redirect to http://example.org/another-url 回答1: location ~ ^(.*)\.html$ { return 301 $1; } 回答2: Probably you need a rewrite statement location /xxx.html { rewrite ^/xxx(.*) http://example.org

Remove index.php from Joomla! URLs with NGINX

前提是你 提交于 2019-12-11 01:15:59
问题 How do I remove index.php from my Joomla URLs? For example: http://domain.com/index.php/webpage should become http://domain.com/webpage I've been following some guides that I've found but it all result in a redirect loop, 404 or internal server error. I need some guidance please. Here is my current config (excluding failing attempts). server { listen [::]:80; server_name www.domain.com; return 301 http://domain.com$request_uri; } server { listen [::]:80; server_name domain.com; root /usr

How to conditionally override a header in nginx only if a cookie exist?

五迷三道 提交于 2019-12-10 18:44:56
问题 Is there a way to check if a specific cookie exist in nginx? For now I have a section like below to set header from cookie: proxy_set_header x-client-id $cookie_header_x_client_id; I want to check if that cookie exist then set the header, otherwise do not override header. I've tried: if ($cookie_header_x_client_id) { proxy_set_header x-client-id $cookie_header_x_client_id; } But it does not work and gives the error below: "proxy_set_header" directive is not allowed here in /etc/nginx/sites

Proxy_pass ignoring port

喜欢而已 提交于 2019-12-06 15:40:44
问题 I have a CentOS server running NGINX listening to 80 and a DB servering an app on 8080. I want to be able to Type http://example.com/dev/abc and have it actually access http://example.com:8080/apex/abc or http://localhost:8080/apex/abc I have used this location configuration location /dev { proxy_pass http://example.com:8080/apex; } However when I try it out the url displayed is http://example.com/apex/apex the page is not found and the log says: 2018/06/14 12:51:33 [error] 7209#0: *2067 open

Proxy_pass ignoring port

守給你的承諾、 提交于 2019-12-04 20:53:31
I have a CentOS server running NGINX listening to 80 and a DB servering an app on 8080. I want to be able to Type http://example.com/dev/abc and have it actually access http://example.com:8080/apex/abc or http://localhost:8080/apex/abc I have used this location configuration location /dev { proxy_pass http://example.com:8080/apex; } However when I try it out the url displayed is http://example.com/apex/apex the page is not found and the log says: 2018/06/14 12:51:33 [error] 7209#0: *2067 open() "/usr/share/nginx/html/apex/apex" failed (2: No such file or directory), client: 124.157.113.187,