yii怎样去掉index.php

2025-10-26
网站建设限时活动促销

具体方法:

(推荐教程:php图文教程)

1、开启apache的mod_rewrite模块

  • 去掉LoadModule rewrite_module modules/mod_rewrite.so前的“#”符号

    立即学习“PHP免费学习笔记(深入)”;

  • 确保DocumentRoot "/Library/WebServer/Documents"中有“AllowOverride All”

  • 重启apache,命令: sudo apachectl restart

2、在项目中的/config/web.php中添加代码:

components'=>array( ...'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => [ '/'=>'/', ], ], )

(视频教程推荐:php视频教程

3、在与index.php文件同级目录下(/web/)添加文件“.htaccess”,内容如下:

Options +FollowSymLinksIndexIgnore */*RewriteEngine on# if a directory or a file exists, use it directlyRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-d# otherwise forward it to index.phpRewriteRule . index.php

标签: index.php

本文地址:https://www.lifejia.cn/news/206987.html

免责声明:本站内容仅用于学习参考,信息和图片素材来源于互联网,如内容侵权与违规,请联系我们进行删除,我们将在三个工作日内处理。联系邮箱:cloudinto#qq.com(把#换成@)