如何在子域中获得Laravel 5的工作。
我已经为laravel核心文件创建了根目录“ api”文件夹,并将“ / public”路径文件拖动到子域文件夹“ App”。
子域app.website.com 域website.com
域网站文件位于htdocs中。 因此laravel文件与根文件夹处于同一级别。
屏幕截图:
我必须更改路由文件中的某些内容吗?
api /路由:
Route::get('/', function(){
// TODO here for your custom routes;
return redirect(env('APP_REDIRECT')); //dashboard
});
include('pages.php');
Route::get('setup/{config}', 'Core\SettingsController@setup');
Route::get('login', 'Core\AuthController@login');
Route::get('img/{path}', 'Core\ImageController@show')->where('path', '.*');
Route::post('error', function(Request $request) {
\Mail::to(env('APP_EMAIL','workemail@gmail.com'))->send(new App\Mail\ErrorReport($request->all()));
return redirect('/')->with(['message'=>'Error report has been submited.','status'=>'success']);
});
Route::group(['middleware' => ['web','auth'], 'prefix'=>'admin'], function () {
Route::get('/', function(){
return redirect(env('APP_REDIRECT'));
});
include('routes.php');
});
Route::group(['middleware'=>['web']],function() {
Route::post('login', 'Core\AuthController@signin');
Route::get('register', 'Core\AuthController@create');
Route::post('register', 'Core\AuthController@register');
Route::get('activation', 'Core\AuthController@activate');
Route::get('remember', 'Core\AuthController@getRemember');
Route::post('remember', 'Core\AuthController@postRemember');
Route::get('reset/{token}', 'Core\AuthController@getReset');
Route::post('reset/{token}', 'Core\AuthController@postReset');
Route::group(['middleware'=>['auth']], function() {
// Dashboard
Route::get('dashboard','Core\DashboardController@index');
// User
Route::group(['prefix'=>'user'], function() {
Route::get('/', 'Core\UserController@getIndex');
Route::get('update', 'Core\UserController@getUpdate');
.......
我知道更改索引文件的第22和36行...似乎是路由问题。
如果重新加载页面,它将快速链接“ / dashboard”更改为“ / login”,然后更改为“ /”
App / .htaccess:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
<IfModule headers_module>
Header set Access-Control-Allow-Methods "GET,POST,PUT,DELETE,OPTIONS"
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Headers "Authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken,Keep-Alive,X-Requested-With,If-Modified-Since"
</IfModule>
# compress text, html, javascript, css, xml:
#AddOutputFilterByType DEFLATE image/jpg
#AddOutputFilterByType DEFLATE image/jpeg
#AddOutputFilterByType DEFLATE image/gif
#AddOutputFilterByType DEFLATE image/png
#AddOutputFilterByType DEFLATE text/plain
#AddOutputFilterByType DEFLATE text/html
#AddOutputFilterByType DEFLATE text/xml
#AddOutputFilterByType DEFLATE text/css
#AddOutputFilterByType DEFLATE application/json
#AddOutputFilterByType DEFLATE application/xml
#AddOutputFilterByType DEFLATE application/xhtml+xml
#AddOutputFilterByType DEFLATE application/rss+xml
#AddOutputFilterByType DEFLATE application/javascript
#AddOutputFilterByType DEFLATE application/x-javascript
# Or, compress certain file types by extension:
<files *.html>
SetOutputFilter DEFLATE
</files>