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 2897
[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: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |