简体   繁体   English

在子域中时如何在根域中上传文件

[英]How upload files in root domain while in subdomain

I've a domain and a subdomain with this structure: 我有一个具有以下结构的域和子域:

Domain: mydomain.com
Subdomain: m.mydomain.com (which "mydomain.com/mobile/" is the folder)

While I'm on mydomain.com, I upload images to the folder "images", this is the structure: 当我在mydomain.com上时,我将图像上传到文件夹“ images”,其结构如下:

mydomain.com/images/image.jpg

And I've no problems with it, because the folder /images/ is in the domain. 而且我没有问题,因为文件夹/ images /在域中。

Now, when I'm in m.mydomain.com, how can I upload images to the domain folder (mydomain.com/images) and not to the subdomain folder (m.mydomain.com/images)? 现在,当我进入m.mydomain.com时,如何将图像上传到域文件夹(mydomain.com/images)而不是子域文件夹(m.mydomain.com/images)?

Thank you guys 感谢大伙们

PS. PS。 I'm using Routing with both domains, with the index.php as "router" 我在两个域中都使用路由,将index.php用作“路由器”

  1. Since m.domain.com is in domain.com you can use m.domain.com/images for both. 由于m.domain.com位于domain.com中,因此您可以同时使用m.domain.com/images。

  2. Use the same directory for both domains and use .htaccess to route the mobile to index.m.php or something like that in the same directory. 两个域使用相同的目录,并使用.htaccess将移动设备路由到index.m.php或同一目录中的类似目录。

  3. More complicated. 更复杂。 You can serve files through a url page built in php. 您可以通过php内置的url页面提供文件。 Basically just a page that takes the file name searches for it in the server directory outside the site and dumps the content with appropriate headers. 基本上,只有一个带有文件名的页面会在站点外部的服务器目录中搜索该文件,并转储带有适当标题的内容。

  4. Similar to 2 you can route both mobile and normal to the same directory. 与2类似,您可以将移动目录和普通目录都路由到同一目录。 Detect in index.php if the subdomain is specified and load the site files from your mobile folder. 在index.php中检测是否指定了子域,并从您的移动文件夹中加载站点文件。 This is my preferred method. 这是我的首选方法。

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

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