/    Sign up×
Community /Pin to ProfileBookmark

Webpage Redirect Codes

Folks,

What are the various ways page redirects are generally done all over the internet ?
Show me some code samples, if you may, as I need to teach my searchengine crawler to watchout for these codes and not index pages that got these redirects.

Cheers!

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@developer_webauthorOct 30.2021 — @NogDog

Do you know Javascript aswell as php ? How many langs you know ? Care to show some redirect codes ?
Copy linkTweet thisAlerts:
@freewpOct 31.2021 — You can check demo on this page when you download sth: [https://freewp.io/](https://freewp.io/)

**Code**:

&lt;?php<br/>
/*<br/>
Template Name: Redirect Page<br/>
*/

// get the redirection url from GET variable<br/>
$redirect_to = !empty($<EM>_GET['url'])<br/>
? trim(strip_tags(stripslashes($_</EM>GET['url'])))<br/>
: '';

$wait_time = 15000; // auto navigation time (in milliseconds - this is 30000 ml = 30s).<br/>
$wait_seconds = $wait_time / 1000;

add_action('wp_head', 'redirect_to_no_index', 99);<br/>
function redirect_to_no_index()<br/>
{<br/>
?&gt;<br/>
&lt;!-- disable indexing this page --&gt;<br/>
&lt;meta name="robots" content="noindex, follow"&gt;

&lt;?php<br/>
}

add_action('wp_head', 'redirect_to_external_link');

function redirect_to_external_link()<br/>
{<br/>
global $redirect_to, $wait_seconds, $wait_time;
<br/>
<i> </i><CODE>if (empty($redirect_to) || empty($wait_time)) {
<i> </i>return;
<i> </i>}
<i> </i>?&gt;

<i> </i>&lt;script&gt;var redirect = window.setTimeout(function(){window.location.href='&lt;?php esc_html_e($redirect_to); ?&gt;'},&lt;?php echo $wait_time; ?&gt;);&lt;/script&gt;
<i> </i>&lt;noscript&gt;&lt;meta http-equiv="refresh" content="&lt;?php echo $wait_seconds; ?&gt;;url=&lt;?php esc_attr_e($redirect_to); ?&gt;"&gt;&gt;&lt;/noscript&gt;</CODE>

&lt;?php<br/>
}

get_header(); //show headers <br/>
?&gt;<br/>
&lt;div id="redirect-page-content" style="width: 100%; background:#fff; height: 50%; margin: 0px 0px 0px 0px; font-size: 15px;"&gt;<br/>
&lt;div class="redirect-message" style="text-align: center; margin-top: 20px"&gt;<br/>
&lt;?php if (!empty($redirect_to)) {<br/>
//echo '&lt;p style="font-size: 95%;margin: 8px !important; color: #191919;"&gt;YOU ARE TRANSFED TO THE FILE DOWNLOAD PAGE&lt;/p&gt;';<br/>
//printf(__('&lt;strong style="margin: 8px !important;"&gt;%s&lt;/strong&gt;'),esc_html($redirect_to));<br/>
?&gt;<br/>
&lt;p style="font-size: 150%;margin: 8px 0px 20px 0px !important;color: #0076b4;"&gt;&lt;strong&gt;AUTOMATICALLY GO TO FILE DOWNLOAD PAGE IN &lt;span style="color: #f50c0c" id="timer"&gt;&lt;/span&gt; SECONDS &lt;/strong&gt;&lt;/p&gt;
<br/>
<i> </i><CODE> &lt;?php
<i> </i> } else {
<i> </i> _e('Broken redirect link');
<i> </i> }
<i> </i> ?&gt;
<i> </i> &lt;/div&gt;</CODE>
&lt;/div&gt;<br/>
&lt;script&gt;<br/>
document.getElementById('timer').innerHTML = &lt;?php echo $wait_seconds;?&gt;;<br/>
var timer = &lt;?php echo $wait_seconds;?&gt;;<br/>
var interval = setInterval(function() {<br/>
var seconds = timer;<br/>
if (seconds &gt; 0) {<br/>
--seconds; <br/>
document.getElementById('timer').innerHTML = seconds + "";<br/>
timer = seconds;<br/>
}<br/>
else {
<br/>
}
<br/>
}, 1000);<br/>
&lt;/script&gt;<br/>
&lt;?php <br/>
get_footer(); //show footer<br/>
?&gt;
Copy linkTweet thisAlerts:
@developer_webauthorDec 21.2021 — @freewp#1638869

Thanks man!

I missed your post!

Anymore you got ?
×

Success!

Help @developer_web spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...