zxcvb12 发表于 2017-12-25 15:36:13

CentOs中Apache文件访问去除index.php

  0.apache下面和index.php同一个目录下面的 .haccess
  

<IfModule mod_rewrite.c>  RewriteEngine on
  RewriteCond
%{REQUEST_FILENAME} !-d  RewriteCond
%{REQUEST_FILENAME} !-f  RewriteRule
^(.*)$ index.php?s=/$1   

</IfModule>  

  1.centos的配置文件放在: /etc/httpd/conf/httpd.conf
  

LoadModule rewrite_module modules/mod_rewrite.so  

  将前面"#"去掉,如果不存在则添加上句。
  2.如果你的网站是根目录的话:找到
  

<Directory />  Options FollowSymLinks
  AllowOverride None
  

</Directory>  

  将上面的None改为All
  3.如果你的站点不在根目录,设置如下:
  

<Directory "/var/www/html/my_directory">  
  Order allow,deny
  
  Allow from all
  
  AllowOverride All
  

</Directory>  

  然后重启服务器,service httpd restart ,这样.htaccess就可以使用了
  4.index.php (thinkphp3.2.3版本)
  define('__APP__', ''); //将index.php自动隐藏
页: [1]
查看完整版本: CentOs中Apache文件访问去除index.php