路由定义
Route::get('/hello', function () {
return 'hello,world!';
});
当使用命令“php think run”运行时,主页访问路径:http://localhost:8000
.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>
访问http://localhost:8000/hello,可得到“hello world”
而当我将代码放入phpstudy中,不使用“php think run”运行
访问http://www.mytp6.com/hello时,会报404错误
修改.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>
再次访问http://www.mytp6.com/hello,成功输出“hello world”