: Nginx location rewrite: match /{?x}, {y}, {?z}. Remove y I am trying to run CiviCRM with Drupal 7 in a docker container of my own design. Unfortunately, I am running into a problem where for
I am trying to run CiviCRM with Drupal 7 in a docker container of my own design.
Unfortunately, I am running into a problem where for some unknown reason CiviCRM is outputting resource requests malformatted. Sometimes like this ('...' conotates the rest of the path to the resource):
/... (good)
/civicrm/... (good)
Sometimes like this:
/civicrm/sitename/... (bad)
Sometimes like this:
/sitename/... (bad)
Sometimes like this:
/civicrm/sitename/civicrm (bad)
Sometimes like this:
/civicrm/sitename/civicrm/sitename/... (very bad)
And so on, possibly infinitum:
/civicrm/sitename/civicrm/sitename/civicrm/... (very bad)
Now regex's are not my forte. After much humming and harring, I have managed to produce the following:
location /civicrm/sitename {
rewrite ^/civicrm/sitename/(.*)$ /;
}
location /sitename/ {
rewrite ^/sitename/(.*)$ /;
}
Now many of the resources load better but this does not catch all of the problems. The best I can define it is this:
#If the URL contains a / followed by any characters or none followed by a / followed by sitename followed by any characters or none, remove sitename:
rewrite /(?./)sitename/(?.)$ $;
# Then continue processing the next directive. #If the rewritten URL contains /civicrm/ more than once, remove all instances of /civicrm/ then add it once:
rewrite /(?./)civicrm/civicrm/(?.)$ /civicrm/$;
Any help?
More posts by @Turnbaugh106
1 Comments
Sorted by latest first Latest Oldest Best
If the URL contains a / followed by any characters or none followed by
a / followed by sitename followed by any characters or none, remove
sitename:
rewrite ^(.+)/sitename(/.*)$ ;
Explanation: you need to capture everything before () and after () the match, in order to construct the result.
If the rewritten URL contains /civicrm/ more than once, remove all
instances of /civicrm/ then add it once:
rewrite "^(.*?)(?:/civicrm){2,}(/.*?)$" /civicrm;
Explanation: As above, except that two or more non-capturing /civicrm strings are matched and the first and last capture are lazy. Expressions containing a { should be quoted.
Useful resource for regular expressions is here.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.