- 通过域名路由闭包的形式,限制域名
Route::domain('news',function(){
Route::rule('details/:id','Address/details');
});
Route::domain('news.tp.com',function(){
Route::rule('details/:id','Address/details');
});
Route::domain(['news','blog','live'],function(){
Route::rule('details/:id','Address/details');
});
Route::rule('details/:id','Address/details')->domain('news');
Route::rule('details/:id','Address/details')->domain('news.abc.com');
- 跨域请求
当不同域名进行跨域请求的时候,由于浏览器的安全限制,会被拦截。为了解除这个限制,我们通过路由allowCrossDomain() 来实现;
Route::rule('details/:id','Address/details')->ext('html')->allowCrossDomain();
实现跨域请求比没有实现的 header 头文件多了几条开头为Access 信息 限制跨域请求的域名,则可以增加一条参数
Route::rule('col/:id','Collect/red')
->allowCrossDomain([
'Access-Control-Allow-Origin' => 'http://news.abc.com:8080'
]);
|