user5839 user5839 - 1 year ago 153
Apache Configuration Question

Rewrite folder to subdomain with htaccess for cross domain issues

I've followed the instructions in Rewrite folder to subdomain and I'm running into a problem

RewriteRule ^cdn/([^/]+)/?$ [NC,R=301,L]

I'm expecting to redirect to but instead it's redirecting to which doesn't help me.

This attempt is to get around cross domain issues. Can anyone let me know how to make it rewrite how I need it, and also if this is likely to solve the video cross domain issues?

Answer Source

You lack $1 at the end of your RewriteRule. Also you need rules for cdn. subdomain to tell that all your content is in cdn folder:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^cdn\$ [NC]
RewriteRUle ^cdn - [L]
RewriteCond %{HTTP_HOST} ^cdn\$ [NC]
RewriteRUle ^(.*)$ cdn/$1 [L,NC]

RewriteCond %{HTTP_HOST} ^(www\.)?$ [NC]
RewriteRule ^cdn/([^/]+)/?$$1 [NC,R=301,L]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download