Hello, DPers and php gurus. I need a virtual subdomain manage script . I am looking for the script. I know several steps of setting subdomain. First step is to set wildcard subdomain eg *.yourdomain.com Now I need the script . The script should be light weight, non-database, flexible and manage subdomain automatic management in php backend . Pls suggest me the script! Thanks.
What exactly should the script do? Are you offering free website hosting or do you just need the redirection code for the wildcard subdomains?
I am not sure if I have express what I want clearly. It is as following. subdomain document path and folder a1.yourdomain.com root/a1/ b2.yourdomain.com root/b2/ verb.yourdomain.com root/verb/ news.yourdomain.com root/news/ The subdomain and the folder can be created and deleted in admin backend . I need the script, light weight and without database .
Well, this should get you started. Place this in your .htaccess file in your public_html folder: Options +FollowSymLinks Options +Indexes RewriteEngine On RewriteCond %{ENV:REDIRECT_STATUS} ^$ RewriteCond %{HTTP_HOST} !^www\.yourdomain\.com$ [NC] RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)\.yourdomain\.com$ [NC] RewriteRule (.*) /$1 [L] HTML: This should redirect anything.yourdomain.com to yourdomain.com/anything. Change in the above code yourdomain to your domain name, then if you are not using a .com change .com to the ending of the domain, like .net. That slash in there needs to be there. Then after that all you would need is the part of the script that makes the folders. Why do you not want a database? The database would be the best way to keep track of which folders exist. What will be in the folders? Hope it helps, Brandon
at first i am very thanks to you to introduce this code to us seconed i have tried to test it many times but nothing happened i have created aaa folder and but .htaccess to it and also to puplic_html folder and nothing happen also tried to delete it from aaa folder and nothing happen i have saved file with format UTF-8 and also in ANSI and nothing happen are there any something to make it work
Did you change the yourdomain and the .com part to match your domain? Is wildcard subdomains enabled? The code should be in a file called .htaccess in the public_html folder of your site. In that case, if you go to aaa.yoursite.com does it redirect to yoursite.com/aaa? You may get a 404 not found page or a directory listing, the 404 if the folder does not exist and the directory if it does. If you get a browser cannot connect error then wildcard dns is not enabled. If you get something else, or you get a 404 but you shouldn't be then post what you get here as far as an error / path.
BMR777, Thanks for you feedback. I google around and find the facts. Basically, there are three steps to set wildcard dns/subdomains. First is setting wildcard dns in domain management panel. Second is setting wildcard dns in hosting setting. (usually we have to ask hosting company to do it) Third is using .htaccess files or subdomain redirection script to manage subdomains. I would like the solution of redirection scripts. Because, I have .htaccess files in root folder, I can't modify the .htaccess file. Plus, I don't want to all folders in root directory to be a "subdomain" . That is why I am looking for scripts that can redirect some folders to subdomains .
Oh, so you want to redirect from a subfolder to a subdomain? So yoursite.com/folder goes to www.folder.yoursite.com? And you can't edit the root .htaccess at all?