vim /etc/php.ini
cgi.fix_pathinfo = 1 #将注释去掉
httpd.conf
查找 LoadModule rewrite_module 和 modules/mod_rewrite.so
如果存在,且以#开头,请删除#。
根目录 .htaccess
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]
</IfModule>
tp5 app/route.php
//引入系统类
use think\Route;
Route::rule([
'/'=>'index/index/index',
'news'=>'index/news/index',
// 如果隐藏id的话
// 'detail-:id'=>'index/news/detail',
],'','get|post');
Route::rule('detail/:id','index/news/detail','get');
前端界面
<a href="{:url('/detail/5')}">新闻-{$v}</a>