【问题标题】:How change root folder with files according to sub domain like wordpress themes如何根据子域(如 wordpress 主题)更改带有文件的根文件夹
【发布时间】:2020-09-05 17:39:31
【问题描述】:

我花了几天时间研究互联网,但我找不到答案。

我有 abc.com 网站,我在 .htaccess 的帮助下获得了子域地址,但是如何根据子域显示不同的主题。

解释。 用户创建子域flower.abc.com 和vegetable.abc.com 等我从数据库php 中根据子域获取用户选择的主题,但我不知道如何更改根链接和根目录

目录

/index.php  
     //theme folder   
flower/index.php   
....../css/  
...../js/

vegetable/index.php  
....../css/   
...../js/  
etc more theme available

但是当用户vegetable.abc.com选择主题蔬菜然后显示主题蔬菜当用户选择花卉主题然后显示花卉主题。

vegetable.abc.com/vegetable/index.php  
to   
vegetable.abc.com/index.php

【问题讨论】:

  • 也许这会有所帮助。请参阅此answer中的大规模虚拟主机部分@

标签: php html css


【解决方案1】:

你可以使用 .htaccess

vegetable.abc.com/vegetable/index.php   

vegetable.abc.com/index.php

.httaccess 文件中的规则

RewriteEngine On

RewriteCond %{HTTP_HOST} ^vegetable\.abc\.com\/vegetable\/index\.php [NC]
RewriteRule ^$ https://vegetable.abc.com/index.php [R=302,L]

虚拟主机

<VirtualHost *:80>
    ServerAlias *.example.com
    VirtualDocumentRoot /var/www/%1/
</VirtualHost>

【讨论】:

  • 如果我采用这种方法,我们需要输入所有主题名称.htaccess 文件如果公司发展超过千主题,这不是一个好技术
  • 我认为您需要在虚拟主机中进行配置,因为您是动态绑定每个域都有单独的文件
  • 我已经在我的项目中使用通配符域,但我的情况有点不同,我对无限通配符域使用相同的源,例如:abc.name.com 它看起来是 abc 页面,123.name.com 页面看起来像 123 页,但我使用了单个源文件,例如:wix.com
猜你喜欢
  • 1970-01-01
  • 2021-05-29
  • 2018-04-16
  • 1970-01-01
  • 1970-01-01
  • 2011-07-15
  • 1970-01-01
  • 1970-01-01
  • 2014-06-19
相关资源
最近更新 更多