Welcome! Log In Create A New Profile

Advanced

Location try_files rewrite syntax

Location try_files rewrite syntax
August 22, 2015 11:48AM
Hi

background: - LEMP stack serving drupal, roundcube, phpmyadmin and postfix/dovecot email server.

Roundcube & phpmyadmin symlinked to the root of the drupal installation

When I disable clean URL's I can access both roundcube and phpmyadmin interfaces by going to

https://mysite.co.uk/roundcube or https://mysite.co.uk/phpmyadmin

However the problem I have arises when I enable clean URL's. I've managed to do so using this tutorial (http://wiki.nginx.org/Drupal) specifically these two config lines : -

location / { try_files $uri @rewrite; } &
location @rewrite { rewrite ^ /index.php; }

with clean urls enabled my drupal site works as expected but when i try to access roundcube or phpmyadmin i get a 404 error message

What is the simplest solution to keep clean urls working and get roundcube and myphpadmin working at the same time?

i've tried to exclude the roundcube & myphpadmin directories from the rewrite and this works to a point

i amended the above two config lines as follows:

location /(!roundcube|phpmyadmin) { try_files $uri @rewrite; }

location @rewrite { rewrite ^ /index.php;

doing this enables clean urls and allows me to access roundcube & phpmyadmin at https://mysite.co.uk/roundcube and https://mysite.co.uk/phpmyadmin however it then requires all subpages of my drupal website to be access with a ? symbol

so https://mysite.co.uk/contact-us becomes https://mysite.co.uk/?contact-us

if anyone has the time to read through the above and has a simple solution to remove the ? then it would be greatly appreciated

thanks
Re: Location try_files rewrite syntax
August 23, 2015 04:45AM
looks like i should have searched harder as i think i found the solution in this post

http://forum.nginx.org/read.php?11,16398,17787

all i had to do was amend the rewrite config location @rewrite { rewrite ^ /index.php; to the following

location @rewrite { rewrite ^(?!(/roundcube/)|(/phpmyadmin/))(.*) /index.php;

this now means clean urls are working for drupal and roundcube & phpmyadmin can also be accessed as required

mods, please mark as solved/closed
thanks
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 124
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready