zl程序教程

您现在的位置是:首页 >  .Net

当前栏目

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

2023-02-18 16:29:43 时间

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

<IfModule mod_rewrite.c>
     RewriteEngine on
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteRule ^(.*)$ index.php?s=/$1 [QSA,PT,L]
</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自动隐藏