Yii的路由配置
取消index.php
這兩種方法都是在自動添加index.php
方法一:使用.htaccess
添加.htaccess文件? 與index.php同級?
RewriteEngine on # if a directory or a file exists, use the request directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # otherwise forward the request to index.php RewriteRule . index.php方法二:vhost
<VirtualHost *:80>ServerName public.oa.comDocumentRoot "D:\phpStudy\PHPTutorial\WWW\OA\frontend\web"<Directory "D:\phpStudy\PHPTutorial\WWW\OA\frontend\web"># use mod_rewrite for pretty URL supportRewriteEngine on# If a directory or a file exists, use the request directlyRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-d# Otherwise forward the request to index.phpRewriteRule . index.php# use index.php as index fileDirectoryIndex index.php# ...other settings...# Apache 2.4Require all granted## Apache 2.2# Order allow,deny# Allow from all</Directory> </VirtualHost>Yii配置
'urlManager' => [//美化路由'enablePrettyUrl' => true,//不啟用嚴格解析'enableStrictParsing' => false,//index.php是否顯示'showScriptName' => false,//偽靜態化 seo'suffix' => '.html',//美化規則'rules' => [//第一條:文章詳細頁'<controller:\w+>/<id:\d+>'=>'<controller>/detail',//第二條:文章列表頁'post'=>'post/index',],],?
總結
- 上一篇: 快手上的小改牛是连车一起卖的吗还是只是改
- 下一篇: 先科应急启动电源厂家在哪