• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

Thinkphp中去除URL里的index.php

php 搞代码 3年前 (2022-01-22) 18次浏览 已收录 0个评论

例如你的原路径是 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 //在APACHE里面去配置

<Directory "D:/server/apache/cgi-bin">AllowOverride none 改 AllowOverride ALLOptions NoneOrder allow,denyAllow from all</Directory>

3.确保URL_MODEL设置为2,

在项目的配置文件里写

return Array('URL_MODEL' => '2',);

4 .htaccess文件必须放到跟目录下

这个文件里面加:

<IfModule mod_rewrite.c>RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]</IfModule>

补充:在windows下不能建立以点开头的文件,你可以先随便建立一个文件

然后在DOS在操作 rename xxxx.xxxx .htaccess

或者打开记事本写入htaccess然(、本文来源gao@!dai!ma.com搞$$代^@码网*搞gaodaima代码后另存为.htaccess即可

如果出现403错误则将.htaccess打开在开头添加Options +FollowSymLinks

即:

Options +FollowSymLinks<IfModule mod_rewrite.c>RewriteEngine onRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]</IfModule>

即可解决.
无权限也是加上Options +FollowSymLinks

相关推荐:

ThinkPHP中关联查询实例,ThinkPHP关联实例

以上就是Thinkphp中去除URL里的index.php的详细内容,更多请关注搞代码gaodaima其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Thinkphp中去除URL里的index.php

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址