linux apache Thinkphp5 只有首页显示,其它页面404, 设置不能使用ip,只能通过域名访问网站

在ThinkPHP5.0中,出于优化的URL访问原则,还支持通过URL重写隐藏入口文件,下面以Apache为例说明隐藏应用入口文件index.php的设置。

下面是Apache的配置过程,可以参考下:
1、httpd.conf配置文件中加载了mod_rewrite.so模块,  开启虚拟主机,这一条必须开启
2、AllowOverride None 将None改为 All,不是httpd.conf   是配置httd-vhosts.conf, 原因是因为apache 只识别index.php ,index.html,

配置如下图

 

3、在应用入口文件同级目录添加.htaccess文件,内容如下:

<IfModule mod_rewrite.c>
  Options +FollowSymlinks -Multiviews
  RewriteEngine On

  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>

 

posted @ 2018-11-28 10:05  Gosun  阅读(2829)  评论(0编辑  收藏  举报