I have seen many issues in the internet with this problem im having but they are all ver broad and hard to pin point exactly whats wrong with it, as there can be many variables to it, so I decided to list everything I have tried and maybe someone could help me.
URL trying to access
Controller
Directory app/Http/Controllers/DirManagements/GetDirs.php
namespace App\Http\Controllers\DirManagements;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class GetDirs extends Controller
{
public function __construct()
{
}
public function getResult()
{
echo "hi";
}
}
Web route
Route::get('dirs', 'DirManagements\GetDirs@getResult');
PHP artisan route:list
Domain | Method | URI | Name | Action | Middleware
| |GET|HEAD | dirs | | App\Http\Controllers\DirManagements\GetDirs@getResult | web
Nginx Sites-available file
server {
listen 443 ssl;
root /my-dir-to-web;
index index.php index.phtml index.html index.htm index.nginx-debian.html;
server_name mysub.mySite.dev;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
ssl_certificate /etc/letsencrypt/live/something/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/something/privkey.pem; # managed by Certbot
}
Solution
I dont know why laravel didnt include this to their installation docs when setting laravel up. added this to my nginx config and it worked.
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
# pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass unix:/var/run/php7-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Solution
I dont know why laravel didnt include this to their installation docs when setting laravel up. added this to my nginx config and it worked.
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
# pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass unix:/var/run/php7-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}