Link to an old page that already has a permanent redirect
First remove the redirect .htaccess
and redirect to oldPage.php
if the referent is not forceOldPage.php
.
Something like this at the top oldPage.php
is a good start, tweaked and refined as needed.
<?php
// If the referring page isn't "forceOldPage.php"...
if ( !strpos( $_SERVER['HTTP_REFERER'], 'forceOldPage.php' ) ) {
// ...301 redirect to "newPage.php"
header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: /newPage.php" );
die();
}
?>
source to share
One possibility is to assume that "force" (select any row) will not be part of the query string on any page going to oldPage.php. Use RewriteCond and RewriteRule. Then reassign forceOldPage.php to oldPage.php? Force.
RewriteEngine on
RewriteCond %{QUERY_STRING} !force
RewriteRule oldPage.php newPage.php [R=301]
RedirectMatch 301 ^/forceOldPage.php$ /oldPage.php?force
FYI: I tried using HTTP_REFERER as a way to detect if a user came from forceOldPage. However, the referent is not passed to the new page on redirection (at least in my environment).
source to share