tp6作模板时打开网页出现No input file specified.解决办法

问题:使用TP框架做项目时,在启用REWRITE的伪静态功能的时候,首页可以访问,但是访问其它页面的时候,就提示:“No input file specified.”下边讲解如何结局。

解法:默认的public目录下.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>

将其修改为:

<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>

总结:仅仅就是在正则结果“/$1”前面多加了一个“?”号,问题也就随之解决了。

其他:有时打开网页出现如下错误也多数是上面的问题。

You don't have permission to access / on this server.

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.