How to map subdomain root to domain folder

I have a subdomian set up that I want to point to a specific directory.

cdn.domain.com

I want cdn.domain.com to point to domain.com/wp-content/, but not as a redirect, as that will just show cdn.domain.com/wp-content/.

Read More

I want to set the domain root, so that when I write cdn.domain.com it wil display the files located at domain.com/wp-content/.

Does anyone have an idea on how I can do this?

Related posts

Leave a Reply

1 comment

  1. I managed to do what I wanted to accomplish with the following code in the .htaccess file. 🙂

    # Rewrite all requests for wp-content from cdn, so they are fetched from the right place
    RewriteCond %{HTTP_HOST} ^cdn.responseretail.no
    
    # Prevent an endless loop frm ever happening
    
    RewriteCond %{REQUEST_URI} !^/wp-content
    RewriteRule (.+) /wp-content/$1 [L]
    
    # Redirect http://cdn.domian.com/ to the main page (in case a user tries it)
    RewriteCond %{HTTP_HOST} ^cdn.domain.com
    RewriteRule ^$ http://www.domain.com/ [R=301,L]