从域根文件夹重定向到子域文件夹

时间:2014-01-18 16:20:05

标签: .htaccess redirect subdomain root

我想重定向名称结尾的所有图像(“-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]

感谢您的帮助 Ogni

1 个答案:

答案 0 :(得分:0)

你的规则如下:

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]

更新:根据评论:

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