Teach you how to use thinkphp to make short links

小云云
Release: 2023-03-17 16:08:01
Original
3376 people have browsed it

Short links, in layman’s terms, convert long URLs into short URL strings through program calculations and other methods. In this article, we will teach you how to use thinkphp to make short links.

tp framework feels that the path is a bit long, how to optimize it better, how to write pseudo-static

http://www.cn3wm.com/ 3wmkj/yzmsfa/index.php?s=/Home/People/index/id/3.html

Now I want to hide the index.php?s=/Home shadow and change it to

http://www.cn3wm.com/3wmkj/yzmsfa/People/index/id/3.html

How to write this

It’s not in tp Do you provide several routing methods, or rewrite in .htaccess

Set up .htaccess redirection, try the following

Options +FollowSymlinks
RewriteEngine On
RewriteCond % {REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]

Hide index.php You can set define('BIND_MODULE','Home') in the entry file index.php. For details, please check the tp manual

The above content is a tutorial on how to make short links in thinkphp. I hope it can help everyone.

Related recommendations:

PHP implementation of URL long connection generation short link operation

Sina short link generation and restoration short link tutorial

Weibo short link algorithm PHP version

The above is the detailed content of Teach you how to use thinkphp to make short links. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!