Tags
PHP
Asked 3 years ago
30 Jun 2021
Views 679
Miller

Miller posted

301 Redirect In PHP

how to 301 Redirect In PHP ?
pratik

pratik
answered Jun 30 '21 00:00

code for .htaccess

RewriteEngine On
RewriteRule  ^index.php
http://www.newdomain.com/index.html  [R=301]


or for same domain

RewriteEngine On
RewriteRule  ^index.php index.html  [R=301]
denyy

denyy
answered Jun 30 '21 00:00


301 redirect in PHP code

header("HTTP/1.1 301 Moved Permanently");
header("Location: http://www.example.com/categories.html");
header("Connection: close");
exit();

kord

kord
answered Jun 30 '21 00:00

you can use header location direct with 301 as argument

header('Location: www.example.com/index.html', true, 301);
exit;

Post Answer