Yii2路径优化隐藏index.php

1.开启apache-rewrite
LoadModule rewrite_module modules/mod_rewrite.so
相应路径的
Options FollowSymLinks
AllowOverride None
改为
Options FollowSymLinks
AllowOverride All

2.修改web.php

'urlManager' => [
 'enablePrettyUrl' => true,// Disable r= routes
 'showScriptName' => false,// Disable index.php
 'rules'=>[],
],

3.在入口文件同级目录下添加.htaccess文件

<IfModule mod_rewrite.c>

# Options +FollowSymLinks
# IndexIgnore */*
RewriteEngine on
# RewriteBase / #注意放在子目录要注释掉

# 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
</IfModule>

 

 

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理

相关文章

开始在上面输入您的搜索词,然后按回车进行搜索。按ESC取消。

返回顶部