Current location: Hot Scripts Forums » General Community » Script Requests » Need redirection based on server local time


Need redirection based on server local time

Reply
  #1 (permalink)  
Old 11-03-05, 08:11 AM
jose luis jose luis is offline
New Member
 
Join Date: Nov 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Need redirection based on server local time

Good day!

I need to divert unwanted traffic from countries that are 6 to 9 hours behind my local time. It amounts to about 40% of total traffic and is causing problems with the transfer capacity that at the moment I can afford to pay for. They also produce an excess of questions I frequently cannot attend.

I plan to divert this unwanted traffic to a simpler welcome (and excuses) page that would produce a very limited traffic compared with the standard site main page.

The redirection could be based on my local server real time and I would redirect traffic arriving between midnight and 7 AM.

I've checked with hotscripts.com but could not find something adequate. My hosting accept CGI (which I am starting to understand a little after struggling for a while with FormMail and Guestbook) and also PHP. But I know nothing (yet) of PHP. The hosting company is rather collaborative (though they would prefer I buy a transfer capacity extension) and the server is based on Linux

Also I am concerned whether this redirection would affect the spiders like googlebot and others and make me lose position in their rankings. Could I include a robot.txt to prevente this problem?

Could someone help with some free scripts?

Thanks a lot!
Reply With Quote
  #2 (permalink)  
Old 11-03-05, 05:13 PM
koncept
Guest
 
Posts: n/a
php all the way if you cannot use .htconfig

PHP Code:

 if (time() > starttime || time() < end time)
 {
 
header ("location: pleaseleave.htm")
 } 
im not sure about the time() part but other wise that should work it may interfeer with spiders, but you could probaly use a broswer detectoin and say your a bot i'll let you in
Reply With Quote
  #3 (permalink)  
Old 11-04-05, 04:54 AM
jose luis jose luis is offline
New Member
 
Join Date: Nov 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
htconfig?

Thanks, Koncept. I'm a little ashamed for my big ignorance, but I prefer to ask and learn.

What do you refer to with .htconfig? Is it HTML, PHP, other thing I should request to my hosting?

regards,
Reply With Quote
  #4 (permalink)  
Old 11-04-05, 06:05 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
.htconfig is a document that you can place an your server yourself.in it you define the configuration of your website.

you also have .htaccess, .htpasswd those are for restrictions and secured logins on your webserver

Greetz,
UnrealEd
Reply With Quote
  #5 (permalink)  
Old 11-07-05, 01:41 AM
jose luis jose luis is offline
New Member
 
Join Date: Nov 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb Succeed!

I thank you all for your help. It nows seems simple to me and is working, but before your help it looked like a big problem.

However, there are a few details that other memebers who need this kind of redirection (and do not have much knowledge of PHP) should consider:

1. The code I used and does work is:

<?php
if(date("H")<8)
header("location: index_night.html")
?>

This will redirect visitors to a "night" main page, in my case with very few links, from 00.00 to 08.00 hrs.

2. It is very important to include this script as the very first thing in the normal index page (even before the document type declaration). Otherwise the redirection may not be possible.

3. Although it's obvious, I did not realize this in the first tests:

The main index should be renamed "index.php" instead of "index.html".

Regards.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Local Server - Dreamweaver MX 2004 problem mcrob PHP 1 10-27-05 01:34 PM
fetching images from remote server to local server ajay007_bond PHP 1 06-21-05 11:04 PM
Server Time 0ne hour behind mikki ASP 2 12-20-04 03:28 PM
Declared Functions skipper23 PHP 4 12-17-03 10:06 AM
index page not showing up skipper23 PHP 3 12-15-03 01:10 PM


All times are GMT -5. The time now is 11:50 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.