Articles of mod rewrite

Apache2 RequestHeader读取的值是ISO-8859-1而不是UTF-8

这是一个特殊情况,我在我的tomcat前面使用Apache mod_proxy ,并且Apache也使用mod_header添加了带有mod_headers的 RequestHeader。 如果特殊字符在URI中,则它们被读取为ISO-8859-1 。 即使我在规则中写下了一个特殊的价值,比如“hélo”。 如果我的conf文件保存为ISO-8859-1 ,那么确定,但是如果conf文件保存为UTF-8 ,那么它就是KO(在运行时变成)。 我没有find这个编码configuration。 我尝试在Windows和Linux的Apache服务器上。 这里的configuration文件: <VirtualHost *:80> ServerName apache.convertigo.net ProxyPass / http://httpbin.org/anything/ ProxyPassReverse / http://httpbin.org/anything/ RewriteEngine On RewriteRule ^(.*)$ – [E=X_REQUEST_URI:%{REQUEST_URI},E=X_REQUEST_HOST:%{HTTP_HOST},E=X_HTTPS_STATE:%{HTTPS}] RequestHeader set x-request-uri "%{X_REQUEST_URI}e" env=X_REQUEST_URI RequestHeader set x-request-host "%{X_REQUEST_HOST}e" env=X_REQUEST_HOST RequestHeader set x-https-state "%{X_HTTPS_STATE}e" env=X_HTTPS_STATE RequestHeader set x-frontal "apache" RequestHeader set x-helo "hélo" </VirtualHost> 这里是一个testingURL,它回显URI(请参阅X-Request-Uri ): […]

mod_rewrite:重写/到CGI脚本

我有一个虚拟主机,我想重写/像/ cgi-bin / script?123。 我认为这样的事情会起作用,但是这会重写为“/index.html/”。 RewriteEngine On RewriteRule ^/$ /cgi-bin/script.cgi?123 [L] 你怎么能这样做?

mod_rewrite将文件添加到url

以下重写将http://example.com/redirect到http://example.com/www/www.example.com/public_html,而不是http://www.example.com/ 。 /www/www.example.com/public_html是DocumentRoot 。 # Rewrite Rules for Example RewriteEngine On RewriteBase / # Redirect from example.com to www.example.com RewriteCond %{HTTP_HOST} !^www\.example\.com [NC] RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L] 这个redirect是在一个VirtualHost *:80的设置: ServerName example.com ServerAlias www.example.com ServerAdmin [email protected] Options +FollowSymLinks DocumentRoot /www/www.example.com/public_html and the rewrite is inside <Directory /> 任何想法,为什么会这样做? 我查看了Apache手册 ,它说在你的RewriteCond中使用$ {HTTP_HOST}会把主机添加到RewriteRule而不是URL-Path 。 那么这是一个非常常见的重写,我从来没有见过这种情况发生。

清理Apacheconfiguration中的怪物重写列表(mod_rewrite)

你将如何去清理多年积累的大量重写清单? 这个想法是摆脱所有重写和未使用的redirect语句,同时保留所有的工作。 我正在考虑启用RewriteLog并将RewriteLogLevel设置为3或4一天左右,然后parsing整个日志并识别“死”重写,注释掉它们,然后检查日志中是否有新的404。 你必须做一个这样的mod_rewrite清理和/或你有任何其他的想法?

我可以从Apacheconfiguration(基于重写条件)写我的select的日志输出?

我有一些内容仅供通过GeoIP查找并与某些国家/地区匹配的用户使用。 这是通过mod_rewrite完成的,并且一切正常。 我想做的是logging失败的尝试,以帮助debugging应该能够得到这个内容,但不能。 为了做到这一点目前我需要在4的RewriteLogLevel,这意味着在虚拟主机上的所有logging,而不仅仅是我限制的东西。 这是来自mod_geoip自述文件的示例: GeoIPEnable On GeoIPDBFile /path/to/GeoIP.dat RewriteEngine on RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^CA$ RewriteRule \.(gif|jpg|png|css)$ – [L] # don't redirect images and stylesheets RewriteRule ^(.*)$ http://www.canada.com [L] # redirect everything else 我想添加一些像 WriteThisToLog "Denied access to $1 from IP $2 due to calculated country $3" variables都在那里 – 是否有一个指令我可以用来写出Apache的错误日志? 编辑:我会把这个在正确的答案评论,但格式是重要的。 我已经结束了这个: RewriteRule ^(.*)$ http://www.canada.com [L,E=GEOIP_FAIL:1] […]

怎么做 。 匹配所有在Apacheconfiguration?

在httpd.conf里面: rewriterule ^questions/([0-9]+).* … 它匹配/questions/1674/<textarea> ,但不是/questions/1674/<textarea><%2Ftextarea>

在Apache中将URL从子域重写到域

我的networking服务器正在运行Plesk,我的网站结构的一部分是这样的: / /httpdocs (domain root folder, URL: http://www.domain.com) /subdomains /subdomains/blog/httpdocs (blog root folder, URL: http://blog.domain.com) 我在域根文件夹中安装了一个WordPress安装程序,WPconfiguration为在访问www.domain.com时显示一个静态页面,并在访问www.domain.com/blog时显示该博客。 但是,我想redirect(使用mod_rewrite)从http://blog.domain.com/到http://www.domain.com/blog/的所有请求。 几个例子: 访问http://blog.domain.com/archives应访问http://www.domain.com/blog/archives/访问http://blog.domain.com/tag/abc应访问http:// www。 domain.com/blog/tag/abc/ 访问http://blog.domain.com/some-post-title应访问http://www.domain.com/blog/some-post-title 所有这些对用户应该是透明的,地址不应该在浏览器的地址栏上改变。 换句话说,我想要一个URL重写,而不是URLredirect。 用mod_rewrite可以实现吗? 任何人都可以帮助我的.htaccess? 我所有的尝试都失败了

如何根据里面的文件设置VirtualDocumentRoot

我试图设置Apache使用VirtualDocumentRoot指令,但我的网站并不完全相同。 大多数网站都有一个drupal文件夹,它应该是根,但是有一些真正的老的drupal网站,一些rails站点,一些django站点等等,它们希望Document根为/或者其他文件夹。 有没有一种方法来设置基于条件的VirtualDocumentRoot或有没有办法使用RewriteRule / Cond检测/如果有一个drupal文件夹或公用文件夹是不正确的文件夹? 以下是我到目前为止: <VirtualHost *:80> # Wildcard ServerAlias, this is the default vhost if no specific vhost matches first. ServerAlias *.unicorn.devserver.com # Automatic ServerName, based on the HTTP_HOST header. UseCanonicalName Off # Automatic DocumentRoot. This uses the 4th level domain name as the document root, # for example http://bar.foo.baz.com/ would respond with […]

如何使用重写规则来testingcookie中的date?

我发现你不能在下一个Rewrite Cond中使用RewriteCond反向引用作为模式条件。 更新:事实certificate,mod_rewrite不扩展testing模式中的任何variables,所以我实际上只有testing的存在的cookie …任何想法如何实际testing的价值,而不仅仅是存在? RewriteCond %{HTTP_COOKIE} niftyExpire=([^;\ ]+) RewriteRule .*index.html /fake.html [E=niftyExpire:%1,C] RewriteCond %{TIME} <{ENV:niftyExpire} RewriteRule .*fake.html /pass.html [R,L] RewriteRule .*index.html /fail.html [R,L] 谢谢, -Eric

有没有办法看到所有当前的Apache规则?

有没有办法看到所有当前的Apache规则?