• akitaro

    (@akitaro)


    Hello,

    as the title says, I’m looking for a solution to redirect a single page from my site to an external URL if the current time is between
    2 set hours.

    I’ve searched for redirection plugins and URL rotators but any that I found don’t have an option to rotate the URLs by time, only by number of hits or by percent.

Viewing 5 replies - 1 through 5 (of 5 total)
  • brandonzundel

    (@brandonzundel)

    That would be a pretty simple plugin to build (exactly how simple only depends on the exact features you want)

    I’m certainly qualified to build it.

    Thread Starter akitaro

    (@akitaro)

    @brandonzunde

    Well, the features should be as simple as:

    if server time is between xx:xx and xx:xx redirect page to “URL1”
    else redirect page to “URL2”

    brandonzundel

    (@brandonzundel)

    Yep, an easy thing to build out.

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    @brandonzundel Careful, it sounds like you’re soliciting for work and that will get you into trouble in these forums.

    Care to share the code here? In Apache2 you’d do it easily via .htaccess like so above the WordPress section.

    RewriteEngine On
    RewriteBase /
    RewriteCond %{TIME_HOUR}%{TIME_MIN} >1200
    RewriteCond %{TIME_HOUR}%{TIME_MIN} <2359
    Redirect 302 ^old-url-here https://www.some-domain.com/new-url-here
    Redirect 302 ^old-url-here https://www.some-domain.com/other-url-here

    I used 2359 to make it more readable, it should be 0000 though I’ve not tested it. Between 1200 and 2359 you’d get https://www.some-domain.com/new-url-here and outside of that you should get sent to https://www.some-domain.com/other-url-here instead.

    Edit: Use 302 instead.

    Thread Starter akitaro

    (@akitaro)

    Thank you @jan Dembowski for your reply,

    I did as you said and now my .htaccess looks like this:

    RewriteEngine On
    RewriteBase /
    RewriteCond %{TIME_HOUR}%{TIME_MIN} >1100
    RewriteCond %{TIME_HOUR}%{TIME_MIN} <0200
    Redirect 302 ^https://domain1.com/old-page/ https://domain1/page.html
    Redirect 302 ^https://domain1.com/old-page/ https://domain2.com/
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress

    but when I go to https://domain1.com/old-page/ no redirect takes place, it just shows me the page and nothing else happens.
    I’m on a Linux server with Apache 2.2.29 installed.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Redirect page to external URL if current time is between 12:00pm and 24:00pm’ is closed to new replies.