Mind blowing SEO improving and Google rank increasing Signature Rotator SEO Tool.

Thread: 

PHP 301 redirect with message?

Ads
banner
banner
banner
hellboy Offline referral

Posts: 92
Joined: May 2014
Reputation: 0

#1
Member
I know how to 301 redirect using .htaccess file but how can I do it with PHP and show a message after the user has been redirected or before I don't really care?
victor Offline referral

Posts: 638
Joined: Jun 2013
Reputation: 33

#2
Senior Member
You need to return HTTP / HTTPS 301 header first.

PHP Code:
header("HTTP/1.1 301 Moved Permanently"); 

Now you need to specify where the content is permanently redirected.

This will refresh after 3 second ideal for showing message during that time!
PHP Code:
header("refresh:3; http://redirect-site.com"); 
or
This will redirect straightaway!
PHP Code:
header("location: http://redirect-site.com"); 

To show redirect message.

PHP Code:
echo 'Redirect message goes here'

Final 301 redirect with message code.


PHP Code:
<?
header
("HTTP/1.1 301 Moved Permanently");
header("refresh:3; http://redirect-site.com");
echo 
'Redirect message goes here';
exit();
?>
hellboy Offline referral

Posts: 92
Joined: May 2014
Reputation: 0

#3
Member
How can I check if HTTP 301 redirect is working?





User(s) browsing this thread: 1 Guest(s)