Home > Common Problem > body text

What should I do if thinkphp5 url rewriting fails?

藏色散人
Release: 2022-12-12 09:31:15
Original
1619 people have browsed it

thinkphp5 url重写不行的解决办法:1、查看httpd.conf配置文件中是否加载了mod_rewrite.so模块;2、将AllowOverride None中的None改为All;3、修改Apache配置文件.htaccess为“RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]”保存即可。

What should I do if thinkphp5 url rewriting fails?

本教程操作环境:Windows7系统、ThinkPHP5版、Dell G3电脑。

thinkphp5 url重写不行怎么办?

ThinkPHP5.1中URL重写.htaccess更改后无效的解决方法

昨天是打算更换项目框架的,决定了这个 ThinkPHP5

开发中一直不喜欢 URL 中有这个index.php,这个时候就要使用.htaccess 来进行 URL 重写,之前有文章大概介绍了一下简单配置.htaccess 就可以实现的几个功能以及.htaccess 文件使用手册,框架都会通过 URL 重写隐藏应用的入口文件index.php,ThinkPHP 框架和 Laravel 框架的入口文件路径一样,都是在public下面

本地开发使用的是 Apache 环境,所以按照官方文档来

httpd.conf配置文件中加载了mod_rewrite.so模块

AllowOverride None 将None改为 All

把下面的内容保存为.htaccess文件放到应用入口文件的同级目录下

<IfModule mod_rewrite.c>
  Options +FollowSymlinks -Multiviews
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
Copy after login

对于模块什么的都是之前配好的,当然是不用改了,心想着是 ojbk 了

原来的访问 URL:

http://serverName/index.php/模块/控制器/操作/[参数名/参数值...]
Copy after login

更改以后应该是

http://serverName/模块/控制器/操作/[参数名/参数值...]

现实是我去访问下面的 URL 不可以访问,提示:No input file specified.

仔细检查一下没有什么问题,应该是官方文档有问题了

TP5.1 的 Apache 配置文件.htaccess,正确配置如下所示:

<IfModule mod_rewrite.c>
  Options +FollowSymlinks -Multiviews
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
</IfModule>
Copy after login

推荐学习:《thinkPHP视频教程

The above is the detailed content of What should I do if thinkphp5 url rewriting fails?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!