前言:phpstudy在apache模式下重写url
1.打开httpd.conf配置文件,ctrl+F 找到:mod_rewrite.so ,去掉前面的#号
2.AllowOverride None 将None改为 All ,注意这是第二个AllowOverride 出现的地方修改为All("D:/phpStudy/Apache/cgi-bin")
3.把下面的内容保存为.htaccess文件放到入口文件的同级目录下
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L]
</IfModule>
4.重启Apache重新访问
若:
发现出现了:No input file specified.
5.解决办法如下:
在Fastcgi模式下,php不支持rewrite的目标网址的PATH_INFO的解析,当我们的 ThinkPHP运行在URL_MODEL=2时,就会出现 No input file specified.的情况,
这时可以修改网站目录的.htaccess文件:
将 RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
改为 RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L]
或把RewriteRule ^(.*)$ index.php?s=$1 [QSA,PT,L]修改为
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
以上代码亲测过,没问题
参考链接:https://blog.csdn.net/wlonging/article/details/53613173