Yii優化路由Apache配置(在APACHE服務器上的訪問方式上去除index.php)
阿新 • • 發佈:2018-07-27
dir rect col acc scrip 例如 web ica tee 在APACHE服務器上的訪問方式上去除index.php
下面我說下 apache 下 ,如何 去掉URL 裏面的 index.php
例如: 你原來的路徑是: localhost/index.php/index
改變後的路徑是: localhost/index
1.httpd.conf配置文件中加載了mod_rewrite.so模塊 //在APACHE裏面去配置
#LoadModule rewrite_module modules/mod_rewrite.so把前面的警號去掉
2.httpd.conf配置文件中 ,將裏面的AllowOverride None都改為AllowOverride All
註意:修改之後一定要重啟apache服務。
2 .添加.htaccess文件放到index.php同級目錄下(入口文件)
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
3.去配置文件web.php中
把下面這段的註釋解開
/*
‘urlManager‘ => [
‘enablePrettyUrl‘ => true,
‘showScriptName‘ => false,
‘rules‘ => [
],
],
*/
Yii優化路由Apache配置(在APACHE服務器上的訪問方式上去除index.php)