简体   繁体   中英

Redirect from domain root folder to subdomain folder

I´d like to redirect all images with name ending ("-554-380"):
Subdomain called: http://static.domain.de

http://domain.de/../..-554-380 -- redirect --> http://static.domain.de/images/..-554-380

My root .htaccess file looks like:

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]

Thanks for your help
Ogni

Have your rules like this:

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]

UPDATE: As per comments:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM