Tags
PHP
Asked 2 years ago
30 Jun 2021
Views 586
Melba

Melba posted

301 redirect .php to non-php page

i did url rewritten for some pages where all page with .php become with .html
like category.php become categories.html like that
but google already noted this all page so i want to redirect this all pages to new html pages .
and it should be 301 redirect , google can note that this page Moved Permanently.

but how to do with 301 redirect .php to non-php page like html
debugger

debugger
answered Jun 30 '21 00:00

php code for 301 redirect as below :


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

header("HTTP/1.1 301 Moved Permanently"); code send the 301 response code
header("Location: code redirect to the given page
header("Connection: close"); close connection
dont forget to exit the execution

Post Answer