I want to create wildcard sub-domains for each user shop using htaccess or any other methodology. But I don't want to create sub-domain folders.
For ex I have URL like:
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. Then in your CP set *.domain.tld to point to a folder.
Now, in notepad or something create a file named index.php, inside that file add this:
<?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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.