【问题标题】:Redirect from domain root folder to subdomain folder从域根文件夹重定向到子域文件夹
【发布时间】:2014-01-18 16:20:05
【问题描述】:

我想重定向所有名称以 ("-554-380") 结尾的图片:
子域调用:http://static.domain.de

http://domain.de/../..-554-380 -- 重定向 --> http://static.domain.de/images/..-554-380

我的根 .htaccess 文件如下所示:

RewriteCond %{HTTP_COOKIE} HTTP_IS_HIDPI
RewriteCond %{DOCUMENT_ROOT}/$1-554x380.$2 -f
RewriteRule ^(static/images.+)-277x190\.(jpe?g|png)$ $1-554x380.$2 [NC,L]

感谢您的帮助
奥格尼

【问题讨论】:

    标签: .htaccess redirect subdomain root


    【解决方案1】:

    有这样的规则:

    RewriteCond %{HTTP_HOST} ^(www\.)?domain\.de$ [NC]
    RewriteRule ^(.+?-554-380)$ http://static.domain.de/images/$1 [L,NE,R=301]
    
    RewriteCond %{HTTP_COOKIE} HTTP_IS_HIDPI
    RewriteCond %{DOCUMENT_ROOT}/$1-554x380.$2 -f
    RewriteRule ^(static/images.+)-277x190\.(jpe?g|png)$ $1-554x380.$2 [NC,L]
    

    更新:根据 cmets:

    RewriteCond %{HTTP_HOST} ^static\.domain\.de$ [NC]
    RewriteRule ^(.+?)-277x190\.(jpe?g|png)$ /$1-554x380.$2 [NC,L] [L,NC,NE]
    

    【讨论】:

    • 谢谢。我只是碰巧这个规则,子域的正确部分还是?但我不知道这个的语法。 RewriteRule ^(static/images.+)-277x190\.(jpe?g|png)$ $1-554x380.$2 [NC,L]
    • 抱歉没明白I have just to chance just this rule, with the right part of the subdomain or?是什么意思你能澄清一下你的问题吗?
    • 我不能“翻译”RewriteRule ^(http://static.domain.de/images.+)-277x190\.. intro .htaccess 兼容语法。
    猜你喜欢
    • 1970-01-01
    • 2014-08-29
    • 2017-12-12
    • 2023-03-09
    • 1970-01-01
    • 2016-11-11
    • 2019-07-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多