Welcome! Log In Create A New Profile

Advanced

Re: Trouble adding /pma location to all virtual hosts

Ben Johnson
June 27, 2013 12:56PM
On 6/27/2013 12:42 PM, Ben Johnson wrote:
> I'm not the type to accept "good enough". I want it to be perfect :).
>
> What would be your preferred course of action to eliminate the internal
> rewrite and instead perform an external redirect for /pma, /PMA, and
> /PMA/ (all redirected to /pma/)?
>
> The documentation states, "There is no syntax for NOT matching a regular
> expression. Instead, match the target regular expression and assign an
> empty block, then use location / to match anything else."
>
> If I'm not mistaken, the location below would match all of the
> "incorrect" variants that I listed above:
>
> location ~* /pma {
>
> }
>
> But then I'm confused as to where the "return 301 /pma/;" needs to be
> placed, if anywhere.
>
> To be clear, I have a "normal website" running on this vhost (a
> customer's own site), so I had assumed that I can't use an empty
> location block, as the manual suggests, and fall-back to "location /".
>
> Somewhat surprisingly, including the above location block actually works
> to redirect /pma, /PMA, and /PMA/ to /pma, while still allowing the
> "normal site content" to function correctly.
>
> Is this because I have the following directive just before the
> PMA-related bit we've been discussing?
>
> location / {
> try_files $uri $uri/ @virtual;
> }
>
> location @virtual {
> if ($uri !~ '/$') {
> return 301 $uri/$is_args$args;
> }
> include /etc/nginx/fastcgi_params;
> fastcgi_pass unix:/var/lib/php5-fpm/web2.sock;
> fastcgi_index index.php;
> fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
> fastcgi_intercept_errors on;
> rewrite ^(.*)$ /index.php?q=$1 last;
> }

A slight correction to part of my last reply.

The location block that actually worked to redirect requests to
incorrect variants of the /pma URL *did* contain the 301 redirect line:

location ~* /pma {
return 301 /pma/;
}

With this block, the "main site" seems to function as expected, and all
of the redirects that I identified previously work as expected.

Is this "incorrect" for any reason?

Thanks again,

-Ben

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Trouble adding /pma location to all virtual hosts

Ben Johnson June 25, 2013 04:20PM

Re: Trouble adding /pma location to all virtual hosts

Ben Johnson June 26, 2013 10:24AM

Re: Trouble adding /pma location to all virtual hosts

Francis Daly June 26, 2013 05:34PM

Re: Trouble adding /pma location to all virtual hosts

Ben Johnson June 27, 2013 12:44PM

Re: Trouble adding /pma location to all virtual hosts

Ben Johnson June 27, 2013 12:56PM

Re: Trouble adding /pma location to all virtual hosts

Francis Daly June 27, 2013 07:10PM

Re: Trouble adding /pma location to all virtual hosts

Ben Johnson June 27, 2013 01:04PM

Re: Trouble adding /pma location to all virtual hosts

B.R. June 27, 2013 01:18PM

Re: Trouble adding /pma location to all virtual hosts

Ben Johnson June 27, 2013 02:10PM

Re: Trouble adding /pma location to all virtual hosts

B.R. June 27, 2013 03:10PM

Re: Trouble adding /pma location to all virtual hosts

Francis Daly June 27, 2013 07:14PM

Re: Trouble adding /pma location to all virtual hosts

Ben Johnson June 28, 2013 02:16PM

Re: Trouble adding /pma location to all virtual hosts

Francis Daly June 27, 2013 07:06PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 146
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