Hello, everyone
I have a web app NEED TO BE deploy under a sub-folder. Of cause I knew how to set up a new Laravel from scratch. My question is what if I want to put it under a sub-folder? like following:
http://test.domain.com/ext_app
after couple hours google my question. I have my web app home page working, just home page. I think that means my Nginx is working, PHP-FPM is working, Laravel is working. But the Laravel router is NOT working, because no matter what I enter the URI, just like http://test.domain.com/ext_app/hello
, http://test.domain.com/ext_app/home
etc..., they always redirect to http://test.domain.com/ext_app
, obviously the route is not working or something I miss configuration?
There're answers said:
configure you public_path or app_path or route_base ..etc
I tried, it's not working. seems the Route
do something else? I'm not sure.
change your Nginx configuration
Yes, I did. It's not working, below is my configuration:
location ~ext_app/((.*)\.(?:css|cur|js|jpg|jpeg|gif|htc|ico|png|html|xml))$ {
rewrite project(\d*)/((.*)\.(?:css|cur|js|jpg|jpeg|gif|htc|ico|png|html|xml))$ /project$1/public/$2 break;
}
location /ext_app {
rewrite ^/ext_app/(.*)$ /ext_app/public/index.php?$1 last;
}
location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_split_path_info ^(.+.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
### laravel rewrite ###
set $laravel_uri $request_uri;
if ($laravel_uri ~ ext_app(/?.*)$) {
set $laravel_uri $2;
}
fastcgi_param REQUEST_URI $laravel_uri;
fastcgi_param LARA_ENV local; # Environment variable for Laravel
### laravel rewrite end ###
fastcgi_param SERVER_NAME $Host;
client_max_body_size 256m;
}
change your code, use Route Group or prefix feature
I tried, invalid, changes like below:
Route::get('ext_app/hello', function(){echo "here!";})
Does Laravel do NOT SUPPORT sub-folder installation or I still got the wrong way?
I need your help.
Any reply will be appreciate.
BR Xiong
did u try make laravel from scratch inside
http://test.domain.com/ext_app
don't forget to chmod -RF 777 storage
dont forget if u use any .htaccess
because it doesnt matter u put any framework anywhere aslong theres the index.php
Try Setting up your file permissions and .hta access, I once created a laravel project in a sub folder but i created that sub folder in the public directory of my first app. all i did is set the .htaccess file
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community