简体   繁体   中英

301 Redirect Root Domain to Subdirectory of Subdomain

I want to redirect my urls from www.example.com/images/ to static.example.com/img/

> RewriteCond %{HTTP_HOST} ^www.example.com/images/$ [NC]
> #RewriteRule ^(.*)$ http://static.example.com/img/$1 [L,R=301]

But i got too many 500 Internal Server Errors. What should i do ?

You can only match host name using %{HTTP_HOST} variable.

You need to use:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^images/(.+)$ http://static.example.com/img/$1 [L,R=301]

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