首页 > Web开发 > 详细

Yii优化路由Apache配置(在APACHE服务器上的访问方式上去除index.php)

时间:2018-07-27 10:01:15      阅读:183      评论:0      收藏:0      [点我收藏+]
在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)

原文:https://www.cnblogs.com/baobaoa/p/9375523.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!