【发布时间】:2018-12-23 19:16:49
【问题描述】:
当用户进入子域(我将有通配符子域)时,我该怎么做,他会看到主域中具有相同名称的子文件夹中的内容?例如,如果用户将进入works.domain.com,我希望他查看www.domain.com/works 中的内容。
这是我的方法:
- 我创建了一个 通配符 子域,例如 *.domain.com
- 使用 index.php 文件在通配符目录中创建了一些子域,因为我可以检查有关此商店的其他信息的首选项 -> 请参阅:
- 现在我的目的是向用户提供他们在 url 中要求的内容
这段代码写在wildcard/index.php文件中
<?php
//Get the store name from url
$host = $_SERVER['HTTP_HOST'];
$url = explode('.', $host)[0];
//Find the store name is it available in the database
$db = new database;
$qri = $db->query("SELECT * FROM store_info WHERE store_name='$url'");
$count = mysqli_num_rows($qri);
//If it returns true then show the reuquested store data
if($count != 0){
*I want to show here the folder data that requested in the url*
}else{
echo 'Store Not found';
}
现在我的问题是:
- 这样做的方法是否正确,那么如何显示请求的文件夹数据?
【问题讨论】:
-
这里对SQL注入开放,你知道吗?
-
是的,我知道我只是在这里展示了一个示例
标签: php .htaccess wildcard-subdomain