服务器之间从一个映像重定向到另一个映像

时间:2013-06-09 20:29:59

标签: .htaccess mod-rewrite url-rewriting

我需要进行一次重定向 - 从一台服务器上的图像到第二台服务器上的新路径。 例如 我有网址 http://example.com/images/main?image=http://example2.com/type/big/picture1.jpg

如何使用htaccess重定向并获取图像“http://example.com/type/big/picture1.jpg

我试过了:

RewriteCond %{REQUEST_URI} images\/main\/.*
RewriteCond %{QUERY_STRING} from=(.*)$
RewriteRule (.*) $1 [NC,L]

我检查了 - $ 1 - 它的REQUEST_URI,但我需要QUERY_STRING 如果我将$ 1替换为定义的图像 - 没关系,但我需要将它用于许多图像。

1 个答案:

答案 0 :(得分:1)

以下代码重写http://example.com/images/main = http://example2.com/type/big/picture1.jpghttp://example.com/type/big/picture1.jpg

RewriteCond %{REQUEST_URI} ^/images/main$
RewriteCond %{QUERY_STRING} from=http://example2.com/(.*)$
RewriteRule .* %1? [NC,L]
相关问题