thinkphp5 url重写不行的解决办法:1、查看httpd.conf配置文件中是否加载了mod_rewrite.so模块;2、将AllowOverride None中的None改为All;3、修改Apache配置文件.htaccess为“RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]”保存即可。
本教程操作环境: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>
对于模块什么的都是之前配好的,当然是不用改了,心想着是 ojbk 了
原来的访问 URL:
http://serverName/index.php/模块/控制器/操作/[参数名/参数值...]
更改以后应该是
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>
推荐学习:《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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

Atom editor mac version download
The most popular open source editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment