Since the default URL access form of the TP3 framework is with index.php, in order to improve the aesthetics of the website and SEO optimization, it is usually desirable to hide index.php. The following describes how to hide index.php in the TP3 framework.
Method 1: Use URL rewriting
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/ [QSA,PT,L] </IfModule>
'URL_MODEL' => 2,
With this method, you can directly use the domain name and routing rules when accessing the website, and you no longer need to bring the index.php section.
Method 2: Modify the configuration file
if (!defined('THINK_PATH')) define('THINK_PATH', __DIR__ . '/ThinkPHP/');
Modify to:
if (!defined('THINK_PATH')) define('THINK_PATH', __DIR__ . '/lib/');
<?php define('APP_DEBUG', true); define('APP_NAME', 'Home'); define('APP_PATH', './Home/'); define('ENGINE_NAME', 'cluster'); require './ThinkPHP/ThinkPHP.php';
Through the above two methods, we can successfully hide index.php in the TP3 framework and improve the user experience and SEO performance of the website. I hope the above information can help developers in need.
The above is the detailed content of The implementation method of hiding index.php in TP3 framework. For more information, please follow other related articles on the PHP Chinese website!