您的位置:首页 > 运维架构 > Apache

Apache重写路由,隐藏index.php

2017-08-02 00:00 309 查看
1、确保Apache配置文件httpd.conf的 mod_rewrite.so 模块开启。方法:去掉前面的 “#”

2、在项目入口文件的同级目录下(即index.php所在目录),新建 .htaccess 文件,内容为:

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、重启Apache,原来的访问地址 http://domainName/index.php/user/login 就可简化为 http://domainName/user/login
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息