Articles of 重写

不区分大小写nginx

我们有几个SEO页面,如: http://www.example.com/PageOne.html 我们在configuration中redirect如下: location = /PageOne.html { rewrite ^/(.*) /seo.php?id=1 last; } 问题是如果用户通过键入以下内容访问此页面: http://www.example.com/pageone.html 显示“找不到页面”错误。 有大约500多个SEO页面。 如何写nginx的规则忽略区分大小写的url? 我想为所有url的通用解决scheme。

nginx用wordpress重写链接

我已经断开了我的WP博客上的链接,这是在这条路线上 www.site.com/wp-content/plugins/download-monitor/download.php?id=1 但是,当我想重新定向到完全新的网站,我的重写规则不起作用。 我用这个 rewrite ^(/wp-content/plugins/download-monitor/download.php?id=1)(.*)$ http://link.com/my.pdf$2 permanent;

Nginx具体重写

我很困惑在nginx重写。 请帮助我,如果可以..谢谢 xxxx.conf #vhost-xxxxx server { listen 80; server_name xxxx.xxxx.com; root /var/www/html; index index.php index.html index.htm; charset utf-8; access_log logs/xxxxxx.access.log; } #rewrite if (!-e $request_filename) { rewrite ^(.+)$ /cn/index.php?q=$1 last; } location ~ \.php$ { root /var/www/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } 你好,我的nginx指向/ var / www / html根目录下的/ var […]

NGINX重写规则应用两次

我想设置NGINX在开发机器上服务OpenUI5应用程序。 我之前从未使用过NGINX,并且在重写url时遇到麻烦。 正如我从跟踪日志中可以看到的,它被应用两次,因此请求404错误的结果。 "^/(?<name>[^/]+)(/(?<something>.*)|/?)$" matches "/HelloWorld/" rewritten data: "/HelloWorld/WebContent/" "^/(?<name>[^/]+)(/(?<something>.*)|/?)$" matches "/HelloWorld/WebContent/index.html" rewritten data: "/HelloWorld/WebContent/WebContent/index.html" 这里是我的NGINXconfigurationpice: location / { root projects; index index.html index.htm; rewrite ^/(?<name>[^/]+)(/(?<something>.*)|/?)$ /$name/WebContent/$something break; } location ~ ^/([^/]+)/resources/(.*)$ { resolver 8.8.8.8; add_header Access-Control-Allow-Origin "*"; proxy_pass https://openui5.hana.ondemand.com/1.34.9/resources/$2; proxy_redirect off; access_log on; } 让我澄清我正在努力解决的任务。 基本上项目看起来像这样: + nginx_root |-+ projects |-+ HelloWorld |-+ WebContent […]

没有文件path的nginx urlredirect

我试图设置nginx让基于Hadoop的集群的名称节点能够根据url上的文件扩展名有效地redirect到Hadoop周围的不同用户界面。 为了简单起见,这样说 firstnode.com对应于我的集群的主节点 stormnode.com对应于运行风暴的节点,并且可以通过端口8080访问UI。 那么,理想的redirect将是http://firstnode.com/storm – > http://stormnode.com:8080 。 我已经尝试编辑我的Nginxconfiguration文件,以便我最终得到像下面的每一个: server{ listen 80; server_name firstnode.com; location /storm{ proxy_pass secondnode.com:8080; } } 以及 server{ listen 80; server_name firstnode.com; location /storm{ return 301 $scheme://secondnode.com:8080$request_uri; } } 以及使用正则expression式对后者进行的等同声明。 不幸的是,我得到的最接近的是将firstnode.com/stormredirect到secondnode.com:8080/storm。 我将不胜感激关于如何通过nginx的configuration文件重写URL而不传递文件扩展名/path(又名/风暴)到新的URL 。

nginx根据url slug重写到同一域下的另一台服务器

让我们假设在domain.com下有现有的web应用程序。 这个程序有不同的语言slu </s> domain.com/ln domain.com(默认语言) 我们需要为domain.com部署新的应用程序,其中domain.com/ln必须保持原样(旧应用程序,而不是我们的代码,不同的平台)。 domain.com/ln可能位于一台物理服务器 1上,其中domain.com将位于物理服务器2 (不同的IP)上? 所以我们假设domain.com的DNS被设置为指向server2 。 然后,当请求domain.com/ln请求被发送到server2 ,但可以在那里redirect(通过IP ??)到server1 ,旧的应用程序正在运行? 谢谢

在根(不是特定的站点)上启用IIS失败的请求跟踪

我有一些URL重写规则在IIS的根(即不在特定的站点)。 他们是在根源,因为他们路由到服务器场,显然这必须在根(我没有看到“路由到服务器场”的选项,当我在网站上创build一个URL重写规则)。 我想启用失败的请求跟踪,所以我可以看到这个特定的规则是怎么回事,但我没有看到一种方式来启用它的根,只有在一个网站的基础上。 如何在根上启用失败请求追踪?

Apache重写规则冲突

我正在研究Apache 2.4中的一个重写规则,其中任何以.pdf /结尾的URL都应该添加一个查询参数并将其转换为.pdf?q ​​= pdf。 例如: http : //www.example.com/us/elections.pdf/应该转换为http://www.example.com/us/elections.pdf?q=pdf 我试图使用下面的规则,它的工作 RedirectMatch 301 ^(。*)。pdf / $ 1.pdf?q ​​= pdf 问题是我们也有一些像{hostname} /us/elections.pdf/ node /img.thumbnail.png 为此,上面的规则是在节点之前添加q = pdf并像{hostname} /us/elections.pdf?q=pdf_node_/img.thumbnail.png 我怎样才能避免这种情况发生? 我怎样才能改变我的规则,使其只适用于.pdf /最后的链接? 任何帮助将是伟大的。

nginx用尾部斜线重写,然后应用更多的规则

重写在不同的Web服务器上总是那些吸pipe,为我打破了驼背。 现在我在服务器configuration中有以下内容: rewrite ^/(.+)$ /index.php?/$1 last; 现在,我需要确认,我在服务器上打开的任何URL都必须得到/ 。 但是,如果URL有参数,尾部/将被忽略。 url可能如下所示: http://domain.tld/testing/ // is okay http://domain.tld/testing // should be redirected with trailing slash http://domain.tld/testing#param // should be left alone 我尝试了以下内容: rewrite ^([^.\#]*[^/])$ /$1/ permanent; rewrite ^/(.+)$ /index.php?/$1 last; 但是它做了什么,它只留下带有斜线的url,但是如果一个url没有,那么它会redirect到http://domain.tld/index.php//testing/甚至是http://domain.tld/index.php//testing/#param使用参数时。

Nginx:将子域映射到代理服务器上的子目录

我有域example.com和子域blog.example.com 。 我有一个运行在localhost:5000的独angular兽应用程序,并使用Nginx作为反向代理。 运行example.com时,我没有任何问题。 不过,我想添加子域支持,并有一些问题。 我在example.com/blog有一些内容。 我想blog.example.com指向它,没有用户知识,使用重写。 我想映射所有的URL,所以: blog.example.com – > localhost:5000/blog blog.example.com/index.php – > localhost:5000/blog/index.php blog.example.com/foo/bar – > localhost:5000/blog/foo/bar 我迄今为止的最佳尝试是这样的: server { listen 80; server_name blog.example.com; location / { proxy_pass http://localhost:5000/blog/$uri; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-Proto $scheme; proxy_redirect off; } client_max_body_size 4G; keepalive_timeout 10; } 这正确地重写blog.example.com ,但与blog.example.com/index.php失败: $ curl -v 'http://blog.example.com' […]