简体   繁体   中英

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/ .

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?

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]

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