php - 如何根据子域(如 wordpress 主题)更改带有文件的根文件夹
问题描述
我花了几天时间研究互联网,但找不到答案。
我有 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
解决方案
你可以使用 .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>
推荐阅读
- c# - 提交用户 ID 和密码时如何禁用 MS Indentity Login.cshtml 页面中的登录按钮
- reactjs - React 自定义钩子以使用 Typescript 和 Material UI 在选择组件上显示值
- python - 为什么将 df 导出到 cvs 不导出第二列?
- c++ - 如何确保正确销毁 vk::UniqueBuffer 和 vk::UniqueDeviceMemory
- php - 不支持 Laravel 7 Argon2 散列
- codeigniter - Codeigniter 4: Loading general settings from DB
- javascript - Fabric.js:在画布中设置新图像但画布没有改变
- xml - 在 XSLT 1.0 中的多个节点中分组并在一个公共元素下输出
- java - 如何在 Eclipse 中修复 jgit 类的 java.lang.ClassNotFoundException
- vue.js - Vue cli 代码未在命令提示符下运行