Articles of mod rewrite

nginx:用所有参数重写一个不存在的php文件到另一个php文件

我真的需要帮助。 现在坐了一会儿,不知道该怎么办。 我想要实现一个非常简单的任务 – 重写一个不存在的PHP文件到另一个前所未有的PHP文件,所有参数如: this http://example.com/nonexistent.php?url=google.com to -> http://example.com/existent.php?url=google.com 我尝试了这样的事情: rewrite ^/nonexistent.php /existent.php; 哪个不工作(文件未find)。 但redirect一个不存在的HTML文件到这样的PHP文件: rewrite ^/nonexistent.html /existent.php; 作品。 我不想重写一个html文件,但这仍然是一个令人困惑的行为。 因此,它也尝试了这样的(和一些变化): rewrite ^/nonexistent.php?url=^(.*)$ /existent.php?url=$1; 这也是行不通的。 (也许语法不好) 任何帮助吗? 这将是非常好的!

Apache重写条件认为目录不是目录?

在我的服务器(Apache2,Ubuntu 10.04)上, wpsa是我的webroot中的一个目录。 当访问url mysite.com/wpsa时,当请求的文件是一个目录时不应该发生的ReWriteRule运行。 这些是我的规则: RewriteCond %{REQUEST_URI} !^/index.php$ RewriteCond %{REQUEST_URI} !^/$ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .* /000_ROUTE.php [L] 这是从重写日志: applying pattern '.*' to uri '/wpsa/' RewriteCond: input='/wpsa/' pattern='!^/index.php$' => matched RewriteCond: input='/wpsa/' pattern='!^/$' => matched RewriteCond: input='/wpsa/' pattern='!-f' => matched RewriteCond: input='/wpsa/' pattern='!-d' => matched rewrite '/wpsa/' -> '/000_ROUTE.php' local path […]

如何添加一个额外的RewriteCond来排除特定的url?

我有一个现有的.htaccess文件与以下rewritecond: RewriteCond %{HTTP_HOST} !^go\.domain\.com$ [NC] RewriteRule ^(.*)$ https://go.domain.com [R,L] 本质上,这个域上的所有内容都被强制go子域。 但是,我想留下一个url,而不是重写: www.domain.com/terms 如何添加额外的RewriteCond来排除这个特定的url?

nginx,apache httpauthentication

我有一个nginx反向代理服务器,与apache后端进入清漆caching。 这个php作为一个从apache开始的fastcgi进程运行。 我试图让一些PHP软件工作,但基本的HTTP身份validation对话框不接受任何用户名或密码。 我做了一些挖掘,并想出了这个.htaccess文件: RewriteEngine On RewriteRule .* – [E=REMOTE_USER:%{HTTP:Authorization},L] 这已经解决了基本HTTPauthentication的authentication问题。 现在我一直在试图弄清楚到底做了什么,所以我的问题是:为什么添加这个重写规则使authentication开始工作? 我现在所能想到的就是在nginx – > varnish – > apache链的某个地方,apache没有收到auth头文件。 我想了解这里发生了什么事情,所以我可以在服务器级别实施更改,以防止其他地方发生。 有人可以澄清? 谢谢

Apache / Tomcatredirect

我们有一个来自Apache前面的供应商的Tomcat应用程序,但是我们没有访问应用程序代码。 我们在应用程序中包含了自己的单一标志,因此如果用户在应用程序中单击“注销”,用户将被带到未使用的“login”屏幕。 我们希望将该login屏幕redirect到默认的Tomcat页面,但我似乎无法获得正确的语法。 我已经尝试了一些调整,没有运气(转义/等)。 有没有人有任何想法? 我已经有一个HTTP到HTTPSredirect工作(包含在下面的指令)。 “注销”链接经过几个redirect,最终结束于: http : //ourserver.com/abc/login 为了简单起见,我们希望将login页面的任何请求redirect到: http : //ourserver.com/ <VirtualHost *:80> RewriteEngine On RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L] RewriteRule ^/abc/login$ / [L] </VirtualHost>

htaccess重写给出LimitInternalRecursion错误

我有一个.htaccess文件与下面的代码 <IfModule mod_rewrite.c> Options -MultiViews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule> 但是当我访问我的网站时,我得到这个错误 [client 127.0.0.1] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace. LogLeveldebugging不会给我一个回溯,我不认为增加内部recursion限制是明智的。 有没有人有这种types的错误的经验?

redirectApache HTTP请求到HTTPS除了当请求是一个POST?

我已经安装我的apache2configurationredirecthttp请求到https。 这工作正常但是我想改变它,所以只有当这个请求不是一个POST请求时才会这样做。 这是我目前的configuration: RewriteEngine On RewriteCond%{HTTPS}!=开启 RewriteRule ^ /?(。*)https://%{SERVER_NAME} / $ 1 [R,L] 我怎样才能改变这个configuration,以便它只在请求不是POST时redirect?

当在%{REMOTE_ADDR}上匹配时,RewriteCond在我的IP上不匹配

我想要一个mod_rewrite规则,当stream量从内部networking到达networking服务器时不会被执行。 Web服务器是apache 2.2下面的RewriteCond是为了防止重写规则。 RewriteCond %{REMOTE_ADDR} !=192\.168\.[0-15]\.[1-255] 如果我使用ip 192.168.15.173访问web服务器,规则似乎没有踢,因此尽pipe我的内部地址执行重写规则。 我的错误在哪里? 匹配更简单: RewriteCond %{REMOTE_ADDR} !=192\.168\.15\.173 也失败了。 我使用http://httpd.apache.org/docs/trunk/rewrite/access.html中的“Blocking of Robots”示例来构build规则。 我错过了什么吗? 编辑:我已经试图调查使用重写日志,但没有提出任何有用的信息。 这是请求过程中发生的事情: 192.168.15.173 – – [12/Jun/2013:13:50:17 +0200] [example.com/sid#7f3c6afb5e30][rid#7f3c6f864b68/initial] (2) init rewrite engine with requested uri /test/ 192.168.15.173 – – [12/Jun/2013:13:50:17 +0200] [example.com/sid#7f3c6afb5e30][rid#7f3c6f864b68/initial] (3) applying pattern '^/test/(.*)' to uri '/test/' 192.168.15.173 – – [12/Jun/2013:13:50:17 +0200] [example.com/sid#7f3c6afb5e30][rid#7f3c6f864b68/initial] (2) rewrite […]

debugginghtaccess重写规则; 第二个捕获组($ 2)为空

我已经看到了这个问题,为其他人,但在他们的情况下,他们的正则expression式有一个问题。 快速浏览regexpal.com向我表示,事实并非如此。 我有一个简单的htaccess文件,允许我将URL写为“.htm”或“.html”,而不是“.php”。 我刚刚发现这个脚本在处理查询string(?argument = value)时有问题。 这是我完整的.htaccess代码: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)\.html?\??(.*)$ $1.php?$2 [nc] 当我打印我的请求的查询string时,它总是空出来,当然,对array_key_exists的检查没有find我想要指定的id。 我不用Apache的工作,但我认为这将是非常简单的。 如果重要的话,这个htaccess应用在一个相对简单的XAMPP设置之上。 我不认为我甚至对httpd.conf文件做了什么。 我可以尝试提供任何其他人们认为可能相关的信息。

你能解释在RewriteRule中的替代吗?

我有一个.htaccess文件中的以下声明 RewriteCond %{HTTP_HOST} ^myOldDomain\.com$ [NC] RewriteRule ^(.*)$ https://myNewDomaink.com/$1 [R=301,L] 它工作正常。 我基本上find了一些示例代码,并将其修改为我的具体目的。 我不太明白的是: 为什么$ 1在主机名之后引用提供的url部分 – 这里的文档在哪里? RewriteCond中没有反向引用。