修改apache配置文件去除thinkphp url中的index.php


修改apache配置文件去除thinkphp url中的index.php

例如你的原路径是 http://localhost/test/index.php/index/add
变成 http://localhost/test/index/add

如何去掉index.php呢?
1、httpd.conf配置文件中加载了mod_rewrite.so模块 //在APACHE里面去配置
#LoadModule rewrite_module modules/mod_rewrite.so把前面的警号去掉

2、AllowOverride None 将None改为 All
Options None 改为 Options All
注意:在APACHE里面去配置 (注意其他地方的AllowOverride也统统设置为ALL)

<Directory "D:/wampp/apache/cgi-bin">
AllowOverride none 改 AllowOverride ALL
Options None 改 Options All
Order allow,deny
Allow from all
</Directory>

<Directory "cgi-bin">
#AllowOverride None
#Options None
AllowOverride all
Options all
Order allow,deny
Allow from all
</Directory>
------------------------------------
配置了别名的例子:
Alias /wnwweb "d:/wamp/www/wnwweb/"
<Directory "d:/wamp/www/wnwweb/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>

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]
</IfModule>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM