richardk wrote:I suppose somewhere you would use the $_GET array, so you can capture the username?
No. This function works like time() and other functions that run with no arguments and just return a value. So if i wanted to know the current time stamp, i'd use
- Code: Select all
<?php
$current_time = time();
?>
and $current_time would hold the value.
So to use this function, all you'd do (as long as it was included) would be run the function:
- Code: Select all
<?php
include('some_file_with_function_in_it.php');
$username = getUsername();
?>
and $username would hold the username. You don't need $_GET or anything.
it can then ditermin which /perhaps which stylesheet to load up.
Then, based on the $username variable, you could do anything, eg. a personalised stylesheet:
- Code: Select all
<?php
include('some_file_with_function_in_it.php');
$username = getUsername();
echo '<style type="text/css"> @import url(/css/' . $username . '.css); </style>';
?>
So it'd be "/css/richard.css" from the subdomain "www.richard.domain.com".
Hi Richardk, hanging from tbobker´s post ,instead of opening a new thread i have a doubt :
I want to use a similar php script on my index page, so when a user hits :
ANYSUBDOMAIN.mydomain.com , .htaccess forwards to mydomain.com, and i can catch ANYSUBDOMAIN, so i know what my users are typing for a subdomain ...
The subdomain's folders doesn´t exist, and i dont want to create them dynamically neither, i just want to know the name of the subdomain they are typing.
Searching on google for dynamic subdomains,i found out that i needed to add a CNAME for (*) and pointed it to my domain, (im hosting with godaddy.com) and they told me the same, after doing it so, instead of having a "page not found" message, now i get a "You don't have permission to access / on this server, Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request. " message.
I tried using an Error document 403, but it is not working, i tried having more support from godaddy, but they refused.
So, how can i tell apache via .htaccess that when it gets a request like this
ANYSUBDOMAIN.mydomain.com, it redirects to mydomain.com
I´ve seen some of your replies from similar questions, and i tried using this :
- Code: Select all
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.)?DOMAIN$ [NC]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} ^([^\.]+)\.DOMAIN$ [NC]
RewriteRule .* /%1%{REQUEST_URI} [QSA,L]
But i still get the "forbidden,permission error".
Hope u have a clue of what to do here.
Thks in advance.