I want to access the Ravel app by specifying the URL of a subdirectory with no butt slash.

Asked 1 years ago, Updated 1 years ago, 116 views

I wanted to publish Ravel's project at the URL of the subdirectory because each server requires a certificate for a name-based virtual server.If you set it up and connect with hoge.com/subdir, it will be "NotFoundHttpException". If you put a slash "/" on your bottom and set it to _ttp://hoge.com/subdir/, it will work.

The environment is as follows:

  • CentOS 6.8
  • Nginx 1.10.2
  • PHP 5.6
  • PHP-FPM 5.6.29
  • Lavel 4.2

The Nginx configuration is as follows:
/etc/nginx/conf.d/subdir.conf

server{
    listen80;

    server_name hoge.com;

    error_log/var/log/nginx/error.log notice;
    rewrite_logon;

    # Remove tracking flash to please routing system.
    rewrite^(.+)/$1;

    location/
    {
        try_files$uri$uri//index.html/index.php?$query_string;
    }

    location~^/index.php${
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME$ document_root$fastcgi_script_name;
        fastcgi_split_path_info^(.+\.php)(.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
    }

    # For subdir
    location~^/subdir(/(.+))?$ {
        root/var/www/Code/subdir/public;

        try_files$1/subdir/index.php?$query_string;

        location~^/subdir/index.php${
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME$ document_root/index.php;
            fastcgi_split_path_info^(.+\.php)(.+)$;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
        }
    }
}

There is larvel42-starter-kit on the github, which works without a butt slash.In laravel 42-starter-kit, most of the packages related to Symphony were 2.5 but in my app, it was 2.7 .Forced "composer update" with "laravel42-starter-kit" resulted in Symphony 2.7 and similarly "NotFoundHttpException" in the butt slash URL request.It may be caused by a package other than Symphony that is installed in the composer, but I suspect it is a routing error.By the way, even after installing Ravel 4.2 and 5.1 in the original state, the display of the first demo screen showed the same NG state.
I'm worried about whether I can avoid it by setting up Nginx, how to do with the composer package of the app, or whether I should approach it by setting up Ravel and correcting the app code.I followed it on XDebug, but I couldn't get to the cause because I was a beginner.

If anyone knows the solution or has similar problems, please reply.

php nginx laravel

2022-09-30 21:22

1 Answers

It seems that the bottom slash is called a trailing slash.(I just looked it up lol)
By the way, here's how it works= (http://wa3.i-3-i.info/word11910.html
) Ravel seems to erase the trailing slash (slash at the end of the URL) by default.
The following is the default.Why don't you take a look around here?

public/.htaccess

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

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


2022-09-30 21:22

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.