2013-11-15 201 views
1

我有一个subdomian设置,我想指向特定的目录。如何将子域根映射到域文件夹

cdn.domain.com 

我想cdn.domain.com指向domain.com/wp-content/,但不是作为一个重定向,因为这将只显示cdn.domain.com/wp-content/

我想设置域根目录,这样当我写cdn.domain.com它将显示位于domain.com/wp-content/的文件。

有没有人有关于我如何做到这一点的想法?

+0

是域/子域在同一台服务器上并共享相同的文档根? –

+0

@JonLin是的,他们是,他们做:) – iamchriswick

回答

0

我设法用.htaccess文件中的下列代码完成我想完成的任务。 :)

# 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]