How to implement custom URLs in PHP: 1. Configure the htaccess file through mod_rewrite to implement URL rewriting; 2. Use the PATH_INFO function that comes with PHP to implement rewriting.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
How does php implement a custom url?
1. Configure the .htaccess file through mod_rewrite to implement URL rewriting, which requires the server to support rewrite
2. Use the PATH_INFO function that comes with PHP to implement rewriting, and implement it through the PHP program.
Related introduction:
pathinfo() function returns information about the file path in the form of an array.
The returned array elements are as follows:
[dirname]: Directory path
[basename]: File name
[extension]: File suffix name
[filename]: File name without suffix
Syntax
pathinfo(path,options)
Parameters
path required. Specifies the path to be checked.
options Optional. Specifies the array elements to be returned. The default is all.
Possible values:
PATHINFO_DIRNAME - 只返回 dirname PATHINFO_BASENAME - 只返回 basename PATHINFO_EXTENSION - 只返回 extension PATHINFO_FILENAME - 只返回 filename
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to implement custom url in php. For more information, please follow other related articles on the PHP Chinese website!