我有一个 subdomian 设置,我想指向一个特定的目录。
cdn.domain.com
我想cdn.domain.com
指向domain.com/wp-content/
,但不是重定向,因为那只会显示cdn.domain.com/wp-content/
。
我想设置域根目录,以便在编写cdn.domain.com
时显示位于domain.com/wp-content/
.
有谁知道我该怎么做?
我设法用 .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]