Thinkphp中重写仍不能去除index.php

去除index.php,配置好了不能去除原因就在于不用的PHP版本重写规则不同

1.httpd.conf配置文件中加载了mod_rewrite.so模块 //在APACHE里面去配置

#LoadModule rewrite_modulemodules/mod_rewrite.so把前面的警号去掉

2.AllowOverride None 讲None改为All //在APACHE里面去配置 (注意其他地方的AllowOverride也统统设置为ALL)

AllowOverride none 改 AllowOverrideALL
Options None
Order allow,deny
Allow from all


3.确保URL_MODEL设置为2,在项目的配置文件里写
return Array(
        'URL_MODEL' =>'2',
);

4 .htaccess文件必须放到跟目录下
这个文件里面加:
<IfModule mod_rewrite.c>
  RewriteEngine On

  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  #RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]   # 适用PHP5.6版本以下
  RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]  # 适用 PHP5.6版本及以上
</IfModule>

发布了6 篇原创文章 · 获赞 4 · 访问量 2376

猜你喜欢

转载自blog.csdn.net/dahai_PHP/article/details/80314809