2

我改变了我的 URL 在我的服务器上的工作方式。现在www.myserver.com/service不是www.myserver.com/test/service

我已将 RedirectMatch 301 添加到我的 Apache conf 文件中,以将任何访问重定向www.myserver.com/testwww.myserver.com/.

我通过这个 URL 的 HTTP PUT 接收文件到这个服务器,例如: www.myserver.com/test/service/put/myfile.xml

发送文件的服务器不处理 301 HTTP 状态代码,因此文件不再到达。

当它是 PUT 请求时,有没有办法重写 URL,以免错过任何文件?

谢谢,

本杰明


更新 :

这是应用此之后的 RewriteLog 内容:

RewriteEngine on
RewriteCond %{REQUEST_METHOD} =PUT
RewriteRule ^/test/(.*) /$1 [PT]

日志 :

XX.XXX.XXX.XXX - - [16/May/2010:06:33:40 +0000] [www.myserver.com/sid#7f378508aa30][rid#7f378538a828/initial] (2) init rewrite engine with requested uri /test/service/put/myfile.xml
XX.XXX.XXX.XXX - - [16/May/2010:06:33:40 +0000] [www.myserver.com/sid#7f378508aa30][rid#7f378538a828/initial] (3) applying pattern '^/test/(.*)' to uri '/test/service/put/myfile.xml'
XX.XXX.XXX.XXX - - [16/May/2010:06:33:40 +0000] [www.myserver.com/sid#7f378508aa30][rid#7f378538a828/initial] (4) RewriteCond: input='PUT' pattern='=PUT' => matched
XX.XXX.XXX.XXX - - [16/May/2010:06:33:40 +0000] [www.myserver.com/sid#7f378508aa30][rid#7f378538a828/initial] (2) rewrite '/test/service/put/myfile.xml' -> '/service/put/myfile.xml'
XX.XXX.XXX.XXX - - [16/May/2010:06:33:40 +0000] [www.myserver.com/sid#7f378508aa30][rid#7f378538a828/initial] (2) forcing '/service/put/myfile.xml' to get passed through to next API URI-to-filename handler
XX.XXX.XXX.XXX - - [16/May/2010:06:33:40 +0000] [www.myserver.com/sid#7f378508aa30][rid#7f3785393858/subreq] (2) init rewrite engine with requested uri /service/put/myfile.xml
XX.XXX.XXX.XXX - - [16/May/2010:06:33:40 +0000] [www.myserver.com/sid#7f378508aa30][rid#7f3785393858/subreq] (3) applying pattern '^/test/(.*)' to uri '/service/put/myfile.xml'
XX.XXX.XXX.XXX - - [16/May/2010:06:33:40 +0000] [www.myserver.com/sid#7f378508aa30][rid#7f3785393858/subreq] (1) pass through /service/put/myfile.xml

更新 2:

阿帕奇配置:

RewriteEngine on
RewriteLog "/etc/httpd/logs/rewrite.log"
RewriteLogLevel 9
RewriteCond %{REQUEST_METHOD} =PUT
RewriteRule ^/test/(.*) /$1 [PT]
RedirectMatch 301 ^/test/(.*)$ http://www.myserver.com/$1
AliasMatch ^/style/(.*)?$ "/var/www/test/www/style/$1"
AliasMatch ^/js/(.*)?$ "/var/www/test/www/js/$1"
AliasMatch ^/min/(.*)?$ "/var/www/test/www/min/$1"
AliasMatch ^/downloads/(.*)?$ "/var/www/test/www/downloads/$1"
AliasMatch ^/images/(.*)?$ "/var/www/test/www/images/$1"
AliasMatch ^/chart/(.*)?$ "/var/www/test/www/graphs/$1"
AliasMatch ^(/.*)?$ "/var/www/test/www/index.php$1"

<Directory "/var/www/test">
    AllowOverride None
    Allow from all
</Directory>
4

1 回答 1

3

mod_rewrite

RewriteEngine on
RewriteCond %{REQUEST_METHOD} =PUT
RewriteRule ^/test/(.*) /$1
于 2010-05-15T02:54:33.397 回答