[英]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.