目前我有我自己的域名示例,如abc.com,但是当我点击另一个页面在abc.com我看到该url有太多的东西,然后我期望,像下面的代码 abc.com/index.html?utm_expid=122964311-0.Ij_8kYLEQneeCz7Rwkt0HA.0&utm_referrer=http%3A%2F%2Fwww.abc.com%2Fpartner.html 我可以知道如何使用nginx重写,使它美丽? nginx.conf server { listen 80; server_name abc.com www.abc.com; root /web/abc/www/phone/; index index.php index.cgi index.pl index.html index.htm; charset utf-8; access_log logs/abc.access.log ; location / { try_files $uri $uri/ /index.html?$args; } 请帮助,先进的感谢。
我们正在转向Apache的一些Nginx服务器。 虽然我们已经使用Nginx的各个网站,它已经在一个最基本的configuration。 但是,我们托pipe的“网站”(实际上是多个)之一是一个沙箱types的网站,以便我们的开发人员可以login到服务器创build一个目录,并且他们有一个网站启动并运行。 我想弄清楚如何用Nginx来复制这个,但是到目前为止我还是无法把头围住。 任何帮助,将不胜感激。 服务器目录设置示例: /home/[USER]/sandbox/site1 /home/[USER]/sandbox/site2 … etc. Apacheconfiguration: <VirtualHost *:80> ServerName example.com ServerAlias *.example.com ServerAlias *.*.example.com RewriteEngine on RewriteCond %{HTTP_HOST} ^(.*)\.(.*)\.example\.com$ [NC] RewriteRule ^(.*)$ /home/%1/sandbox/%2/$1 [L] <Directory /> AllowOverride All Require all granted </Directory> </VirtualHost> 结果域: [USER].site1.example.com [USER].site2.example.com …. etc. 在Nginx中parsing主机并在内部正确路由到所述目录会是什么样子?
我一直在尝试将重写规则从.htaccess转换为nginx重写。 原始文件如下所示: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* index.php?/$0 [PT,L] 转换 if (!-f $request_filename){ set $rule_0 1$rule_0; } if (!-d $request_filename){ set $rule_0 2$rule_0; } if ($rule_0 = "21"){ rewrite /.* /index.php?/$0 last; } 但是当我重新启动nginx时,我得到: nginx:[emerg]未知的“0”variables nginx:configuration文件/usr/local/nginx-1.8/conf/nginx.conftesting失败
我试图redirect/networkingmyfakedomain.com到局域网中的另一个ip xxx.xxx.xxx.120。 也就是说,当我尝试访问myfakedomain.com/net时,它应该显示xxx.xxx.xxx.120的内容 我也正在将http请求redirect到https,如下所示 <VirtualHost *:80> # The ServerName directive sets the request scheme, hostname and port that # the server uses to identify itself. This is used when creating # redirection URLs. In the context of virtual hosts, the ServerName # specifies what hostname must appear in the request's Host: header to # match […]
我想通过使用下面的代码服务器webp图像支持浏览器。 除了同一文件的.png和.jpg图像之外,我已经有.webp图像。 例如,如果有一个名为vacation.jpg的图像,我也有vacation.jpg.webp。 下面的代码工作,但它是覆盖我的其他位置块之前,我切换到CDN。 现在我正在使用CDN的代码块没有任何效果,没有响应的WEBP图像,也没有覆盖我的其他位置块。 这里是如何做到这一点: 添加到/etc/nginx/mime.types “image/webp webp” 添加到主要的nginx.conf文件中: map $http_accept $webp_suffix { default “”; “~*webp” “.webp”; } 添加到服务器块: location ~* ^/wp-content/.+\.(png|jpg)$ { add_header Vary Accept; try_files $uri$webp_suffix $uri =404; } 重新启动或重新加载nginx。 我的其他位置块的示例: 禁用热链接 location ~ .(ico|gif|png|jpe?g|svg|webp)$ { valid_referers none blocked example.com *.example.com; if ($invalid_referer) { return 403; } } 允许跨站点的静态域名文件 location ~ \.(ico|gif|png|jpe?|svg|webp|eot|otf|ttf|ttc|woff|woff2|ogg|js|css|font.css)$ […]
我在我的网站上build立一个新的永久链接结构。 添加了一些nginx重写规则后,有一个redirect循环到/ vlogger / info / info / info / info / … 老永久链接: /vlogger/user-name 新的永久链接: /vlogger/info/user-name 目前的nginx规则: location ~ /vlogger/(.*)$ { rewrite ^/vlogger/info/$1 permanent; } 我如何检查第二个目录(/ vlogger /“info /”)是否设置并redirect成功而没有循环? (*用户名仅包含:a-z0-9和 – (减号))
当用户请求http://sub1.example.com/a/b/c时,我需要将此请求的主机名头replace为example.com,并将path重写为http://example.com/sub1/a/b/ c 。 我试图使用reqrep,但我无法find如何将子域部分添加到path。 reqirep ^Host:\ (.*[^\.])(\.example\.com) Host:\ example.com reqrep ^([^\ :]*)\ (.*) \1\ /???/\2 我find%[req.hdr(host),lower,field(1,'。')]方法来获取子域名,但是我不能在reqrep方法的replace部分中使用它。 如何在这部分使用variables?
我需要在NGINX中创build一个代理重写,其中重写URL由请求的URI中包含的数据组成。 例如: 鉴于url: http:// proxyhost:5555 / go / 222.222.222.222 / action / etc 重写应该是: http:// 222.222.222.222:6666 / action / etc 这在NGIX中可能吗? 我可以在Apache的httpd上做到这一点,但到目前为止我还没有想出如何在nginx上做到这一点 (特定于Apache的例子): RewriteEngine On RewriteBase "/" RewriteRule "^go/(.*)/action/(.*)$" "http://$1:6666/action/$2" [P]
我一定在这里错过了一些非常愚蠢的东西,但我看不见它。 我有以下url格式: https://www.example.com/french/xx/cats_59_H_L.html …和这个规则: rewrite ^/french/.*/cats_([0-9]+)_([AZ])_([AZ])\.html$ /cgi-bin/hotels/related_cats.cgi?ID=$1&start=$2&end=$3&type=chambres&t=french last; 但是,它给出了一个404: 2017/08/30 12:52:59 [error] 8041#8041: *1147655 open() "/home/user/web/example.com/public_html/french/xx/cats_59_H_L.html" failed (2: No such file or directory), client: 81.174.134.133, server: example.com, request: "GET /french/xx/cats_59_H_L.html HTTP/2.0", host: "www.example.com" 更新:好的,以及我已经find了违规的规则,但我正在努力解决如何解决它。 location /french { include /home/fatpeter/conf/web/chambres.com.extra/other-cats-french.conf; } 我的域的主要configuration是: server { listen 111.74.193.98:443 http2; listen [::]:443 http2; server_name example.com www.example.com; root /home/user/web/example.com/public_html; index […]
我们有一个新的CentOS框,我们需要启用漂亮的URL /永久链接。 我们正在运行安装了mod_rewrite的Apache,但是我知道我需要编辑一些configuration文件来启动和运行基础知识。 哪些步骤和文件需要更改才能启动并运行?