i wish to make a site(http://example.com) and allow user to create their own site under http://example.com. When a user register in my site automatically generata a subdomain for that user. thatis http://user1.example.com. The actual files of the user in my server look like this /wwwroot/userfiles/user1. and also i have to make a small banner on each file,user uploaded. Can u help me?
9 2892
[PHP]<? function selfURL() { $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : ""; $protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s; $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]); return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI']; } function strleft($s1, $s2) { return substr($s1, 0, strpos($s1, $s2)); } ?>[/PHP]
put that out of the way somewhere, it basically splits your URL.
[PHP]<?
$url = explode("://", selfURL());
$url2 = explode(".", $url[1]);
$sub = $url2[0];
if($sub != "yourDomain") {
header('location: http://yourDomain.com/'.$sub); } ?>[/PHP]
and theres a redirect, replace all instances of yourDomain with the part BEFORE the .com and AFTER the http:// (Or other respective piece of text). $sub will be your username. put thie BEFORE any html output. including php echoes.
if you have any questions pm me or post here.
where i place these php codes? Can u explain in details..
and thanks for ur help.
i am extremely sorry. i forgot to finish the post
place these codes in the index.php page that you get when you first load your website. Place them at the top of your very first page, and adjust the URLs accordingly.
this way, when the page loads, it checks the URL, and when it sees the subdomain, it will re-direct to the folder with that domain as it's name. if there is no sub domain it keeps you on your home page.
See if this helps
ya i did these things. But i didnt get the output. Plz giv the step by step instruction,if u can.
did you get an error from the browser... if so, post it. i'm going to put a seperate page on my website with this script in it to test it. ill post my results and instructions.
i used this code in my index.php
<? function selfURL() { $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : "";
$protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s;
$port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]);
return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI'];
}
function strleft($s1, $s2)
{ return substr($s1, 0, strpos($s1, $s2));
}
$url = explode("://",selfURL());
$url2 = explode(".", $url[1]);
$sub = $url2[0];
//print $sub;
if($sub != "example") {
header('location: http://example.com/'.$sub); }
?>
and also i created one account "user1"
when am using http://example.com it prints " example"
but when i'm using http://user1.example.com it didnt print "user1" and 403 forbidden appeared in the browser.
the 403 is as i expected. your server is treating the user1.example.com as an actual subdomain, and anything before your server is handled as part of an actual subdomain, not passed to the page, so im stuck there. and yes, i know, the code is sloppy, all my codes are, but it all works just the same.
have the people in the htaccess forum help you out, tihs goes beyond my knowledge
thank you anyway.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Roel Wuyts |
last post by:
CALL FOR CONTRIBUTIONS
International Workshop on Revival of Dynamic Languages
http://pico.vub.ac.be/~wdmeuter/RDL04/index.html
(at OOPSLA2004, Vancouver, British Columbia, Canada, October...
|
by: Keith Jakobs, MCP |
last post by:
Greetings:
I had seen several posts around the Internet about this issue from a few
months back, but have been unable to find a resolution ...
I have a user who is trying to get started with...
|
by: dgk |
last post by:
Not a dotnet question yet, although the site will be dotnet.
Anyway, I have a cable modem and dynamic (although pretty static) IP
address. How can I use a domain name if the real ip can change? I...
|
by: Pascal Costanza |
last post by:
Dynamic Languages Day @ Vrije Universiteit Brussel
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Monday, February 13, 2006, VUB Campus Etterbeek
The VUB (Programming Technology Lab,...
|
by: Nick |
last post by:
Hi eveybody,
I need some help regarding the mecanism to put in place to be able to
dynamically update a remote object when the assembly where it is defined is
modified, and this whitout having...
|
by: tirrell payton |
last post by:
Hello,
I am attempting to validate my user's email addresses by sending them a
link. However, I am having trouble concatenating the variable name (GUID)
into the url. Im using C#:
public...
|
by: Bilz |
last post by:
I am planning to use the CSharpCodeProvider to generate some compiled
functions in my app.
In my current implementation, All of these functions are generated in
one swipe... thus they all invoke...
|
by: Yas |
last post by:
Hi everyone
I am trying to create a DELETE Trigger. I have 2 tables. Table1 and
Table2. Table 2 has all the same fields and records as Table1 + 1
extra column "date_removed"
I would like that...
|
by: avadhesh33 |
last post by:
As we wanr Dynamic Subdomains
It means we want to allow any of text in place of "www" like..
abc.domain.com
xyz.domain.com
.......
*.domain.com
|
by: bprocopio |
last post by:
Please help. I'm stumped.
I need to create a dynamic variable in a procedure that will be used
to update a variable of the same name in a table. i.e. the name in
tblAnalysisScores are...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |