yii去掉index.php的方法:1、開啟apache的mod_rewrite模塊,并重啟apache;2、編輯項目中的/config/web.php文件;3、在與index.php文件同級目錄下添加【.htaccess】文件。
具體方法:
(推薦教程:php圖文教程)
1、開啟apache的mod_rewrite模塊
去掉LoadModule rewrite_module modules/mod_rewrite.so前的“#”符號
立即學(xué)習(xí)“PHP免費學(xué)習(xí)筆記(深入)”;
確保DocumentRoot "/Library/WebServer/Documents"
重啟apache,命令: sudo apachectl restart
2、在項目中的/config/web.php中添加代碼:
components'=>array( ... 'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => [ '<controller:\w+>/<action:\w+>'=>'<controller>/<action>', ], ], )
(視頻教程推薦:php視頻教程)
3、在與index.php文件同級目錄下(/web/)添加文件“.htaccess”,內(nèi)容如下:
Options +FollowSymLinks IndexIgnore */* RewriteEngine on # if a directory or a file exists, use it directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # otherwise forward it to index.php RewriteRule . index.php
以上就是yii怎樣去掉index.php的詳細(xì)內(nèi)容,更多請關(guān)注php中文網(wǎng)其它相關(guān)文章!
PHP怎么學(xué)習(xí)?PHP怎么入門?PHP在哪學(xué)?PHP怎么學(xué)才快?不用擔(dān)心,這里為大家提供了PHP速學(xué)教程(入門到精通),有需要的小伙伴保存下載就能學(xué)習(xí)啦!
微信掃碼
關(guān)注PHP中文網(wǎng)服務(wù)號
QQ掃碼
加入技術(shù)交流群
Copyright 2014-2025 http://m.miracleart.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號