Articles of 重写

将htaccess重写规则转换为nginx

通过search互联网“转换htaccess的nginx规则”我想出了anilcetin和winginx .htaccess的nginx转换器,我怀疑它不能正确输出我所需要的。 以下哪项更准确? 你能帮我解决这个问题吗? 这是我想要转换为Nginx的.htaccess: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ %{ENV:BASE} index.php [QSA,L] 以下是转换器的输出。 Anilcetin if (!-f $request_filename){ set $rule_0 1$rule_0; } if ($rule_0 = "1"){ #ignored: "-" thing used or unknown variable in regex/rew } Winginx # nginx configuration location / { if (!-e $request_filename){ rewrite ^(.*)$ /$env_base index.php break; } }

Nginx的重写模块无法正常工作

我已经阅读了很多关于它的主题,但是解决不了我的问题。 从APache移动到Nginx后,我不能设置重写来处理我的论坛友好的url。 我的论坛位于虚拟服务器的/论坛/位置。 我想要做的就是将/forum/thred-something.html&someaction重写到/forum/showthread.php?tid=ID&action=someaction 我使用这个插件进行名称到ID的转换: https : //github.com/frostschutz/MyBB-Google-SEO 这就是我的虚拟服务器本地化configuration看起来像: server { server_name www.podziemieopowiadan.pl; listen 80; return 301 http://podziemieopowiadan.pl/index.php; } server { server_name podziemieopowiadan.pl; listen 80; access_log /var/log/nginx/podziemieopowiadan-pl_access_log; error_log /var/log/nginx/podziemieopowiadan-pl_error_log; root /var/www/domains/podziemieopowiadan-old; index index.php; allow 188.127.246.50; allow 188.127.242.122; allow 204.93.240.0; allow 204.93.177.0; allow 199.27.128.0; allow 173.245.48.0; allow 103.21.244.0; allow 103.22.200.0; allow 103.31.4.0; allow 141.101.64.0; allow 108.162.192.0; […]

IIS反向代理和URL重写不起作用

我做了以下步骤: 将所有的needefunction安装到IIS(URLRewrite 2.0,ARR,…) 在VisualStudio中创build默认的MVC Web应用程序 添加这个网站应用程序作为iis的新网站(我可以通过http://localhost访问它) 为这个网站打开了URLRewrite 点击Add Rule(s)… selectReverse Proxy inputgoogle.com作为服务器,HTTP请求将被发送 未选中Enable SSL Offloading 点击OK 当我访问http://localhost我仍然拥有自己的webapp,而不是google.com 。 在我的web.config有: <rewrite> <rules> <rule name="ReverseProxyInboundRule1" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{CACHE_URL}" pattern="^(https?)://" /> </conditions> <action type="Rewrite" url="{C:1}://google.com/{R:1}" /> </rule> </rules> </rewrite> 然后,我尝试添加更有用的规则:将localhost/google/sth重写为google.com/search?q=sth 。 我改变了web.config : <rewrite> <rules> <rule name="ReverseProxyInboundRule1" stopProcessing="true"> <match url="^google/(.*)" /> <conditions> <add input="{CACHE_URL}" […]

IIS URL重写为404处理程序

我怎样才能使用IIS中的URL重写模块来模仿一个通用的404处理程序? 设置与特定模式相匹配的重写规则很容易,但是我想要做的是为任何与磁盘(或虚拟文件夹)上的现有文件不匹配的URL设置重写规则。 我也需要知道原始URL是什么,所以我可以进一步处理它。 例如,给出以下请求 HTTP://主机/ foob​​ar的 如果“foobar”parsing为一个实际的文件夹/文件(或虚拟文件夹),它应该像IIS一样正常处理。 如果“foobar”不存在(即服务器通常会返回一个404),则重写规则应该踢入和转发到另一个URL,例如 HTTP://主机/ MY-404-处理原始URL = foob​​ar的 这可能使用URL重写模块? 如果没有,我怎样才能实现它使用其他的IIS工具/技术?

为具有查询string的特定URL设置Access-Control-Allow-Origin Header

我试图在这里作为最后的手段尝试不同的事情/要求谷歌/阅读http://httpd.apache.org/docs/2.2/ 我在我的apache2.conf中有以下内容 # Allow cross domain fonts RewriteCond %{REQUEST_URI} (ttf|otf|eot|woff|svg) [OR] RewriteCond %{QUERY_STRING} (ttf|otf|eot|woff|svg) RewriteRule .* – [E=crossdomain:true] # Cross domain videoplayer config RewriteRule ^/video/player/config.json – [E=crossdomain:1] # Cross domain for fragments RewriteCond %{QUERY_STRING} fragment=true RewriteRule .* – [E=crossdomain:1] # Set header Header set Access-Control-Allow-Origin "*" ENV=crossdomain 所有这一切都很好。 现在,我想要的URL如下所示 Access-Control-Allow-Origin“*” …标题也是: /video/player/sources.json?contentId=AVID20150102_0012&width=640&height=360 正如你所看到的,这样一个URL几乎和上面一行中的一样: RewriteRule ^/video/player/config.json […]

尝试重写/ directory / dir_variable / to /directory/dir_variable/index.php

我试图重写这样的东西: domain.tld / staging / base_1 /到domain.tld / staging / base_1 / index.php其中'1'是一个可变数字。 但是得到一个redirect周期。 *1 rewrite or internal redirection cycle while processing "/staging/base_1//index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php/index.php …. 这里是我正在使用的位置指令,我已经阅读了文档,这似乎是可行的,但我显然缺less一些东西。 location ~* /staging/(.*) { rewrite ^/staging/(.*)$ /staging/$1/index.php last; }

Apache .htaccess规则中的特殊nginx热链接保护转换

在Apache中,我有以下反向重写规则,我希望在nginx中有这个规则。 我看到cookie或引用规则示例。 但是两者都没有结合,所以我不知道如何去做这件事。 <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_REFERER} !^$ [OR] RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?domain\.com.*$ [NC] RewriteCond %{HTTP_COOKIE} !^.*_.*$ RewriteRule \.(flv|jpg|jpeg|mp3|mpg|mp4|mov|wav|wmv|png|gif|swf|css|js|htc|woff|otf|eot|ttf)$ – [F,NS,L] </IfModule> 这是一个轻松的规则,允许空的引用,如果与一个已知的cookie发送(例如_ )。 但是当使用无效的域引用者时,它将拒绝没有设置cookie的访问。

nginx用php解释器重写

首先,我是新的nginx,我正在从Apache切换。 我使用ajenti控制面板设置服务器。 我得到了PHP工作得很好。 然而,当我尝试做一个重写规则,我得到一些奇怪的行为。 我把它放在ajenti控制面板的“自定义configuration”区域。 位置/ bitaddiction { 重写^ / bitaddiction / puzzles /(.*)/bitaddiction/index.php?act=playPage&a=$1 break; } 它很简单,一半的作品。 但是,当我去那个url,我得到一个保存对话框,PHP代码被放在该文件。 我将如何去确保PHP解释它,而不是保存在一个文件?

iptables'重写'在某个端口上的请求?

好吧,我的情况基本上是这样的…我有一个框,充当路由器,有2个接口, eth0和eth1 。 eth1是我的上行链路,就是这个盒子通过它获得一个互联网连接的接口。 eth0是下行链路,也就是其他设备/交换机/无线AP /您将连接的接口。 我想以某种方式,使用iptables,使所有请求端口53任何源于eth0地址,而不是发送到运行在127.0.0.1的DNS服务器,当该DNS服务器发送答复时,发送请求应该看起来像回复来自他们实际发送数据包的地址。 例如,假设有一台连接eth0的机器configuration为使用8.8.8.8作为DNS服务器。 路由器的DNS服务器有一个example.com的logging,指向192.0.2.1 。 连接到eth0的机器上有人运行dig example.com @8.8.8.8 。 他们得到的答复是来自8.8.8.8 ,但ACTUALLY来自路由select框,并且这个答复表示example.com的Alogging是192.0.2.1 。 我怎样才能做到这一点? 请注意,这需要适用于任何DNS服务器地址,而不仅仅是8.8.8.8 。

通过IIS ARR反向代理区分tomcat应用程序响应重写的被调用的URL

嗨到社区在Serverfault! 在尝试configurationIIS以在同一台计算机上的两个Tomcat服务器上打开相应的pipe理器APP时遇到问题。 当我直接通过http://servername:8081/manager和http://servername:8080/manager (另一个Tomcat)调用站点时,一切工作正常。 当我尝试将请求redirect到http://servername/manager7到第一个Tomcat和http://servername/manager8到第二个服务器时,恶梦开始了。 HTML Resonse中的链接总是包含/ manager7 / …即使我调用URL http://servername/manager8 。 以下是我的重写规则。 我把它们设置在服务器级别。 <rewrite> <globalRules> <clear /> <rule name="Tomcat7" enabled="true" patternSyntax="Wildcard" stopProcessing="true"> <match url="*7*" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false" /> <action type="Rewrite" url="http://wwwts02:8081/{R:1}{R:2}" /> </rule> <rule name="Tomcat8" enabled="true" patternSyntax="Wildcard" stopProcessing="true"> <match url="*8*" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false" /> <action type="Rewrite" url="http://wwwts02:8080/{R:1}{R:2}" /> </rule> </globalRules> <outboundRules> <clear […]