shedokan
11-25-2007, 02:01 AM
Hello,
Is there a way to check if a user entered www. before the url?
thanks.
Is there a way to check if a user entered www. before the url?
thanks.
|
||||
how can I check the url?shedokan 11-25-2007, 02:01 AM Hello, Is there a way to check if a user entered www. before the url? thanks. GO ILLINI 11-25-2007, 03:08 AM Yes, you can check inside the $_SERVER['SERVER_NAME'] global. -Adam shedokan 11-25-2007, 01:09 PM doesn't works. fl00d 11-25-2007, 06:28 PM It does work. I just added it into a regular expression. <?php $url = $_SERVER['SERVER_NAME']; $regexp = "^\www+.\.com$"; if(!ereg($regexp,$url)){ echo "no!"; }else{ echo "yes!"; } ?> Check the $_SERVER global (http://ca.php.net/reserved.variables). shedokan 11-25-2007, 06:41 PM apperantly it doesn't works with sub-domains fl00d 11-25-2007, 06:56 PM Just edit the regular expression. Perhaps you should study PHP a bit more. shedokan 11-25-2007, 07:02 PM I did a test where: I tried to echo $_SERVER['SERVER_NAME'] and one time I put the www and the other time I didn't and the result was the same in both of the times and only echoed the url without www Inigoesdr 11-25-2007, 08:32 PM Use $_SERVER['HTTP_HOST'] or $_SERVER['SCRIPT_URI'] if you want the full requested path. shedokan 11-25-2007, 10:15 PM nope the same thing. Inigoesdr 11-25-2007, 11:26 PM Awesome. Well, maybe next time you give a useless response why don't you include some diagnostic information that might help us. Information like errors, the code you're using, the value of the variables, the expected result, and the actual result. aWishResigned 11-25-2007, 11:30 PM Awesome. Well, maybe next time you give a useless response why don't you include some diagnostic information that might help us. Information like errors, the code you're using, the value of the variables, the expected result, and the actual result. :eek: Wow... Shedokan, check out http://us.php.net/reserved.variables. It should have the info you're looking for. shedokan 11-26-2007, 02:29 PM what I need is one of these: <?php echo $_SERVER['SERVER_NAME']; echo '<br>'; echo $_SERVER['HTTP_HOST']; echo '<br>'; echo $_SERVER['SCRIPT_URI']; ?> but I can't use them because I'm using a subdomain. there is this htaccess script: RewriteEngine on RewriteCond %{HTTP_HOST} ^subdomain.domain.com [NC] RewriteRule ^(.*)$ http://www.subdomain.domain.com/$1 [L,R=301]' but my webhost doesn't supports it yet. Inigoesdr 11-26-2007, 08:43 PM Run this code, and post the output: echo '<pre>' . print_r($_SERVER,1) . '</pre>'; shedokan 11-27-2007, 02:59 AM Array ( [SCRIPT_URL] => /hello.php [SCRIPT_URI] => http://neostar.110mb.com/hello.php [HTTP_HOST] => neostar.110mb.com [HTTP_CONNECTION] => keep-alive [HTTP_ACCEPT] => */* [HTTP_REFERER] => http://www.110mb.com/ [HTTP_ACCEPT_LANGUAGE] => he-il,en-us;q=0.7,ru-RU;q=0.3 [HTTP_UA_CPU] => x86 [HTTP_ACCEPT_ENCODING] => gzip, deflate [HTTP_USER_AGENT] => Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; MRA 4.10 (build 01952); .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 1.1.4322) [HTTP_X_FORWARDED_FOR] => 1.1.1.1 [PATH] => /usr/local/bin:/usr/bin:/bin [SERVER_SIGNATURE] => [SERVER_SOFTWARE] => Apache [SERVER_NAME] => neostar.110mb.com [SERVER_ADDR] => 195.242.99.87 [SERVER_PORT] => 80 [REMOTE_ADDR] => 1.1.1.1 [DOCUMENT_ROOT] => /www/ [SERVER_ADMIN] => 110mb.server@gmail.com [SCRIPT_FILENAME] => /www/110mb.com/n/e/o/s/t/a/r/_/neostar/htdocs/hello.php [REMOTE_PORT] => 62440 [GATEWAY_INTERFACE] => CGI/1.1 [SERVER_PROTOCOL] => HTTP/1.1 [REQUEST_METHOD] => GET [QUERY_STRING] => [REQUEST_URI] => /hello.php [SCRIPT_NAME] => /hello.php [PHP_SELF] => /hello.php [REQUEST_TIME] => 1196132170 ) I had to delete a few things like my IP and cookies Inigoesdr 11-27-2007, 03:05 AM Every suggestion given holds the url you were looking for in the original question. |
| |||
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum