国防部重写的子域子域目录
我有一点与重写规则的问题;所以我试图做的就是这一点;
I have a bit of a problem with rewrite rules; so what I am trying to do is this;
[名] .domain.com /文件/为[名] .domain.com /用户/ [名] /文件,
[name].domain.com/files/ to [name].domain.com/users/[name]/files,
其中,[名]是子域名,比如缺口。 重要的是,重定向应该发生的事情,只是,如果请求包含子目录;文件/.
where [name] is sub-domain name, for instance "nick". Important part is that redirection should happened, only, if request contains sub-directory; files/.
例子我能找到谷歌是与子域子目录重定向和子目录其他子目录重定向,从来没有组合这两个例子。
Examples I could find on Google are examples related to sub-domain to sub-directory redirection and sub-directory to other sub-directory redirection, never combination of those two.
尝试把这些规则的.htaccess文件在你的文档根目录:
Try putting these rules in the .htaccess file in your document root:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^([^\.]+)\.domain\.com$ [NC]
RewriteRule ^files/(.*)$ /users/%1/files/$1 [L]
我认为你没有一个 WWW
在你的/用户/所以我增加了!^ WWW \。
状态。如果你的执行的想要www.domain.com去/用户/网络/然后就删除了这一行的请求。
I assumed that you didn't have a www
in your /users/ so I added the !^www\.
condition. If you do want requests for www.domain.com to go to /users/www/ then just remove that line.