I'm trying to make Laravel 4
run in a subdirectory, using .htaccess to be able to rewrite the url to the public folder
Example:
-
C:\xammp\htdocs\laravel4
-
.htaccess
is rewritingC:\xammp\htdocs\laravel4
toC:\xammp\htdocs\laravel4\public
Works correctly for rewriting. However, when I try to create a setting in the routes.php
file, it always returns a page not found.
Example:
If I access localhost/laravel4/teste
, with the configuration below, Laravel says the page was not found.
Route::get('/teste', function(){
return "Hello World";
});
Now, when I do it this way, it shows correctly:
Route::get('laravel4/teste', function(){
return "Hello Word";
});
Between tests and others, I discovered that Laravel 4, when it is going to route the url, does not use $_SERVER['PATH_INFO']
(which would only return the parameters after the public / index.php rewritten), but yes $_SERVER['REQUEST_URI']
(which would return everything that comes after http://localhost/
).
So I can rewrite the url, but I can not configure the routes normally, but only when I use a prefix for the subfolder I'm using.
How to solve this problem without having to change core of Laravel 4?
Is there any way to bypass or prefix these routes internally (Any method in the Route class or some global configuration)?