First open the "index.php" file in the root directory; then determine if "$_SERVER['HTTP_HOST']" is equal to the set domain name and use the function "header()" to The HTTP status code is set to 301; finally jump to the specified URL.
Code sample
$the_host = $_SERVER['HTTP_HOST'];//取得当前域名 if(strtolower($the_host) != 'test.com')//把这里的域名换上你想要的 { $URIRedirect=$_SERVER['REQUEST_URI']; //获取域名后的参数 if(strtolower($URIRedirect)=="/index.php")//判断是参数为/index.php就显示为/ { $URIRedirect="/"; } header("HTTP/1.1 301 Moved Permanently");//发出301头部 header("Location: http://www.test.com" . $URIRedirect);//跳转到你希望的地址格式 exit(); }
Recommended tutorial: "PHPCMS Tutorial"
The above is the detailed content of How to add 301 of PHPCMS?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Notepad++7.3.1
Easy-to-use and free code editor

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
