在做Thinkphp5开发的时候发现在apache下总会在子页面出现“No input file specified. ”,很闹心,总是要自己在请求地址上添加“/index.php?s=/”,之前也大概知道什么问题,操作方式如下
1.去除httpd.conf文件中”#LoadModule rewrite_module modules/mod_rewrite.so”前面的”#”号;
2.修改httpd.conf文件中的AllowOverride None为AllowOverride All,目的是支持.htaccess文件;
# # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # AllowOverride FileInfo AuthConfig Limit # AllowOverride All
3.重启apache sudo apachectl restart
4.修改public目录下的.htaccess文件(有的apache服务器需要这一步):
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
改为
RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L]
最后.htaccess文件内容为:
<IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L] </IfModule>