简体   繁体   中英

HTAccess for Laravel 4 sub directory

Getting really frustrated trying to configure the whole redirecting business. I have laravel as a sub directory to the main root. So instead of doing this:

Route::get('/game/quiz/', 'HomeController@showQuiz');
Route::get('/game/quiz/home', 'HomeController@showQuiz');
Route::get('/game/quiz/boho', 'HomeController@showBoho');
Route::get('/game/quiz/chic', 'HomeController@showChic');
Route::get('/game/quiz/elegant', 'HomeController@showElegant');
Route::get('/game/quiz/glamour', 'HomeController@showGlamour');
Route::get('/game/quiz/quirky', 'HomeController@showQuirky');
Route::post('/game/quiz/submitQuiz', 'QuizController@submitQuiz');

^^ Causes 404's for all public assets

I ideally want this:

Route::get('/', 'HomeController@showQuiz');
Route::get('home', 'HomeController@showQuiz');
Route::get('boho', 'HomeController@showBoho');
Route::get('chic', 'HomeController@showChic');
Route::get('elegant', 'HomeController@showElegant');
Route::get('glamour', 'HomeController@showGlamour');
Route::get('quirky', 'HomeController@showQuirky');
Route::post('submitQuiz', 'QuizController@submitQuiz');

This is my main app htaccess:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule (.*) public/$1 [L]
</IfModule>

Points to public folder which is fine.

now public folder htaccess:

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /index.php [L]

$_SERVER when i dd();

["REQUEST_URI"] "/game/quiz/"
["CONTEXT_DOCUMENT_ROOT"] "/home/sites/mywebsite.co.uk/public_html/"
["SCRIPT_FILENAME"] "/home/sites/mywebsite.co.uk/public_html/game/quiz/public/index.php"
["SCRIPT_URI"] "http://mywebsite.co.uk/game/quiz/"

Help would be greatly appreciated!

Paths are configured in file /bootstrap/paths.php

add /game/quiz to all paths defined in this file. If configured correctly with absolute path or path relative to folder bootstrap then you will get your problem solved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM