[英]Create wildcard subdomain using htaccess in wordpress for different shop users
I want to create wildcard sub-domains for each user shop using htaccess or any other methodology. 我想使用htaccess或任何其他方法为每个用户商店创建通配符子域。 But I don't want to create sub-domain folders.
但是我不想创建子域文件夹。
For ex I have URL like: 对于前我有这样的URL:
https://example.com/wbb/john
and want this URL to become 并希望该网址成为
https://john.example.com
try this: In your DNS, set *.domain.tld to point to your server. 请尝试以下操作:在DNS中,将* .domain.tld设置为指向您的服务器。 Then in your CP set *.domain.tld to point to a folder.
然后,在CP中将* .domain.tld设置为指向文件夹。
Now, in notepad or something create a file named index.php, inside that file add this: 现在,在记事本或其他文件中创建一个名为index.php的文件,在该文件中添加以下内容:
<?php
$UserSubdomain = array_shift((explode(".",$_SERVER['HTTP_HOST'])));
if($UserSubdomain==TRUE){
header("Location: http://example.com/wbb/$UserSubdomain");
}
else{
header("Location: http://example.com/user-not-found");
}
Now, save the file and upload it to the folder. 现在,保存文件并将其上传到文件夹。
This will NOT make the url be john.example.com
but it will send john.example.com
to http://example.com/wbb/john
这不会使url为
john.example.com
但会将john.example.com
发送到http://example.com/wbb/john
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.