Nginx block | redirect url files

0

I'm creating a url shortener in my ex-subdomain (go.domain.com) to serve as an external reference, eg

// a url de uma pagina (extensa)
www.domain.com/user-2124532544454343dgfs-pages-artes-31234124141241241212xxxx

// ficaria assim:
go.domain.com/world-arts

Well this example is pretty "rough" but the problem is that I need to get the url via $_GET in the "go" subdomain and how the "shortened" url points to a subdirectory in "go" use try_files with emphasis in $uri/ directories in the server block nginx settings to complete the request processing ex:

location / {
    try_files $uri $uri/ /index.php?l=$request_uri;
}

Where "l" (location) is the reference for accessing $_GET with PHP and searching the database for registration to redirect.

So far so good once the "shortened" url is correctly accessed badly when you run for example "go.domain.com/image.png" falls into error 404 however 404 is reserved for an error (notfound) within the project.

How to check if the url has a period (.) or another invalid character in any part of it? And so return the index with a $_GET to catch this error?

The closest I came to was this rule:

error_page 400 /index.php?error=bad;

location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|html|htm)$ {
   return 400;
}

However it is not possible to predict all possibilities, a simple /hgaasd.aaa would be enough to throw a 404 error.

In the case in question the allowed characters would be: alpha-numeric and @ _-

    
asked by anonymous 18.09.2016 / 20:24

0 answers