简体   繁体   English

如何将子域根目录映射到域文件夹

[英]How to map subdomain root to domain folder

I have a subdomian set up that I want to point to a specific directory. 我有一个subdomian设置,我想指向一个特定的目录。

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/ . 我希望cdn.domain.com指向domain.com/wp-content/ ,而不是重定向,因为这只会显示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/ . 我想设置域根目录,以便在编写cdn.domain.com将显示位于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. 我设法通过.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]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM