thinkphp 如何去除url中的index.php-php程序员的笔记

 我来答
百度网友8538c4d
2016-08-26 · TA获得超过105个赞
知道小有建树答主
回答量:212
采纳率:86%
帮助的人:128万
展开全部

tp的官网手册有的啊:

百度搜索:

ThinkPHP3.2完全开发手册

进去后点击部署,然后url重写:

下面我贴出来吧,摘自thinkphp官网手册:

[ Apache ]
httpd.conf配置文件中加载了mod_rewrite.so模块
AllowOverride None 将None改为 All
把下面的内容保存为.htaccess文件放到应用入口文件的同级目录下
<IfModule mod_rewrite.c> 
    RewriteEngine on 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
[ IIS ]
如果你的服务器环境支持ISAPI_Rewrite的话,可以配置httpd.ini文件,添加下面的内容:
RewriteRule (.*)$ /index\.php\?s=$1 [I]
在IIS的高版本下面可以配置web.Config,在中间添加rewrite节点:
<rewrite> 
<rules> 
<rule name="OrgPage" stopProcessing="true"> 
<match url="^(.*)$" /> 
<conditions logicalGrouping="MatchAll"> 
<add input="{HTTP_HOST}" pattern="^(.*)$" /> 
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> 
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> 
</conditions> <action type="Rewrite" url="index.php/{R:1}" /> 
</rule> 
</rules> 
</rewrite>
[ Nginx ]
在Nginx低版本中,是不支持PATHINFO的,但是可以通过在Nginx.conf中配置转发规则实现:
  location / { 
  // …..省略部分代码   
      if (!-e $request_filename) 
      {   
      rewrite  ^(.*)$  /index.php?s=$1  last;   break;    
      } 
  }
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式