Welcome! Log In Create A New Profile

Advanced

Nginx config - redirect everything to index - internal 500 server error

Posted by seba 
Nginx config - redirect everything to index - internal 500 server error
December 31, 2018 07:30AM
I am having the following testing environment structure:

/public/ -> public folder

/public/res/ -> resources folder (css, js)

/public/index.php -> index site (the only publicly used framework
file, everything else is outside public)

What i want to achieve is that every url except resources folder is pointed to index.php?foo=getvars keeping the current url structure in the address bar.

For example:
`/test2/something/something/` points to `/test2/index.php?foo=something/something/`

If possible, i want this redirect including .php files, so that it redirects like any other url instead of showing "no input file" error (hiding php file extensions).

What i tried so far is throwing a 500 internal error

location ~ ^/public/(?!res)(.*) {

try_files $uri $uri/ /test2/index.php?foo=$1;

}

#block direct php access - not working with redirect
#location ~ ^/public/.*\.php$ {

#return 404;

#}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 112
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready