How to Make 301 Redirects with PHP?
Firstly, if we answer how to redirect in PHP,we can say that it is done with the header ()
function. As an example;
<?php
header('Location:http://phpexample.net')
// or time redirects
header('Refresh:2;Url=http://phpexample.net')
What is a 301 redirect, exactly? There is no difference from Normal Redirecting, we just redirecting with 301 code.
The 301 code indicates that the page we redirected here has been permanently moved. We can do this in 2 different way.
header("HTTP/1.1 301 Moved Permanently");
header("Location: http://phpexample.net");
exit
Or more simply;
header("Location: http://phpexample.net", true, 301);
exit;
Comments
Popular Articles
Popular Tags
- #directive
- #Function
- #React
- #Class
- #centOS
- #Json
- #Text
- #API
- #URL
- #Encrypting
- #Redirect
- #Form
- #Special Characters
- #Special
- #Random
- #Generating
- #SASS
- #Version
- #Installation
- #Show
- #
- #Ajax
- #method
- #Logic For Displaying Posts
- #Key
- #DDOS
- #Default Value
- #Comment Line
- #1364 Field
- #Error
- #Abbreviation
- #QR Code Generating
- #Date
- #timeAgo
- #cURL
- #Array
- #Arrays with Key Values to String Statement
- #Short Tag
- #Vite
- #Reading Excel Files
- #Activate
- #Reading
- #Composer
- #Autoloader
- #PSR-4
- #Insert
- #Record
- #Real Time
- #Characters
- #Socket.io
There are no comments, make the firs comment