Warm tip: This article is reproduced from serverfault.com, please click

Redirect all pages to subdomain while keeping the content

发布于 2020-11-30 12:49:15

I want to redirect all my pages and video content to my sub domain (where I have my CDN)

currently I have link in a videogame, with people who generate traffic and I have a lot of link already in the game that I cant change since it will take forever, so I want redirect all people that will click on the link to my sub domain, where I have my CDN setup

https://exemple.com/folder/contents/video.mp4 TO https://cdn.exemple.com/folder/contents/video.mp4

I already try few rewrite command with htaccess but I get the error TOO_MANY_REDIRECT and I don't know what to do

Questioner
ROOT BEER
Viewed
0
Amit Verma 2020-12-02 02:28:52

This should work for you:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule ^(.+\.mp4)$ https://cdn.exemple.com/$1 [R,L]

Put this at the top of your /root/.htaccess before other rules and make sure to Clear your browser cache before testing this new redirect.