【问题标题】:Redirect from one image to another between servers在服务器之间从一个图像重定向到另一个图像
【发布时间】:2013-06-09 20:29:58
【问题描述】:

我需要进行一次重定向 - 从一台服务器上的图像到第二台服务器上的新路径。 例如 我有网址 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 替换为定义的图像 - 没关系,但我需要将它用于许多图像。

【问题讨论】:

    标签: .htaccess mod-rewrite url-rewriting


    【解决方案1】:

    下面的代码将http://example.com/images/main?=http://example2.com/type/big/picture1.jpg改写为http://example.com/type/big/picture1.jpg

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

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-07-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多