thinkphp 项目不能直接域名访问 而要加index.php 才能访问

一.apache 服务器配置问题

vim /usr/local/apache2/conf/httpd.conf

在ifModule这里加入index.php

<IfModule dir_module>
    DirectoryIndex index.html index.php  #这里原来没有index.php
</IfModule>

在加入

<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

此时的.htaccess文件为

<IfModule mod_rewrite.c>
 RewriteEngine on

     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_URI} !(\.html)$ [NC]
     RewriteRule ^/?(.*)$ /$1.html [QSA,R=301,L]

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

#//第二种方法
</IfModule>