Gruntjs 使用grunt contrib connect和connect modrewrite实现超薄路由
我使用它是因为它应该正确地传递QSA标志。到目前为止,索引页可以工作,但没有一个内部页可以工作。这是斯利姆的stock.htaccess文件:Gruntjs 使用grunt contrib connect和connect modrewrite实现超薄路由,gruntjs,rewrite,slim,Gruntjs,Rewrite,Slim,我使用它是因为它应该正确地传递QSA标志。到目前为止,索引页可以工作,但没有一个内部页可以工作。这是斯利姆的stock.htaccess文件: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [QSA,L] 直接使用此选项将加载索引页: rewrite(['%{REQUEST_FILENAME} !-f ^ index.php [QSA,L]']) 正在尝试访问http://127.0.
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
直接使用此选项将加载索引页:
rewrite(['%{REQUEST_FILENAME} !-f ^ index.php [QSA,L]'])
正在尝试访问http://127.0.0.1:9000/news
引发无法获取错误:
Cannot GET /news
这稍微好一点-当您转到/news
时,它将加载index.php,但不会触发路由:
rewrite(['!\\.php|\\.html|\\.js|\\.css|\\.svg|\\.jp(e?)g|\\.png|\\.gif$ /index.php [QSA,L]'])
为了更好的衡量,这里是我的苗条路线,尽管我很确定它不会走这么远:
$app->get('/', function () use($app, $smarty) {
$app->render('home.tpl', array('ParentTemplate' => $smarty->compile_id . '.tpl'));
})->name('home');
$app->get('/news', function () use($app, $smarty) {
$app->render('news.tpl', array('ParentTemplate' => $smarty->compile_id . '.tpl'));
})->name('news');
有人试过这样的东西吗?我一时糊涂
更新
我发现它只适用于regex第二个示例,但看起来它仍然没有传递slim访问正确路径所需的任何信息
更新2
从grunt contrib connect处理$\u服务器变量的方式(我想)可以看出这一点。以下是常规apache:
'SCRIPT_NAME' => string '' (length=0)
'PATH_INFO' => string '/about' (length=6)
connect的服务器只有:
["SCRIPT_NAME"]=> string(1) "/"
Slim将PATH_INFO设置为$requestUri,因此我认为解决这个问题的方法应该是在connect中设置PATH_INFO。现在就开始工作。切换到grunt php并开始工作。切换到grunt php并开始工作