[英]Create wildcard subdomain using htaccess in wordpress for different shop users
我想使用htaccess或任何其他方法为每个用户商店创建通配符子域。 但是我不想创建子域文件夹。
对于前我有这样的URL:
https://example.com/wbb/john
并希望该网址成为
https://john.example.com
请尝试以下操作:在DNS中,将* .domain.tld设置为指向您的服务器。 然后,在CP中将* .domain.tld设置为指向文件夹。
现在,在记事本或其他文件中创建一个名为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");
}
现在,保存文件并将其上传到文件夹。
这不会使url为john.example.com
但会将john.example.com
发送到http://example.com/wbb/john
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.