-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed redirection bug #63
Conversation
In the case of MOD_REWRITE being used on an Apache server to forge the webtrees url, webtrees would try to redirect to its source directory path and would not respect the SERVER_URL site setting (causing an infinite redirect loop)
The ZF library has functions to extract the request URL from the server environment. Would it be better to use that? Perhaps something along these lines...
Does this code pick up your redirection OK? |
Unfortunately, it doesn't. I've looked through all the Zend documentation about the Request classes. It seems that they aren't designed to catch this case. They use the same server variables as Webtrees currently uses. The problem is that Zend applications are designed to have a single entry point
This means unless the file actually exists (images, css etc.) route everything through the file Because Webtrees does not work this way and has multiple entry points e.g. For reference here's the relevant part of my
|
We know the current script name, so it is straightforward to strip that off. The Zend library FYI, the intention is to move to ZF2 and a single entry point (i.e. a front controller). I don't have apache on my dev machine (I prefer nginx), so I'll need to set it up to investigate... |
Thanks! |
In the case of MOD_REWRITE being used on an Apache server to forge the webtrees url,
webtrees would try to redirect to its source directory path and would not respect
the SERVER_URL site setting (causing an infinite redirect loop).
Further explanation:
Suppose the webtrees source is in a folder named
/webtrees
in the document root of the webserver but suppose you want the URL for your site to be something likehttp://example.com/familytree
.Previously webtrees would not handle this situation correctly and set the
WT_SCRIPT_PATH
constant based on its file path (/webtrees
from$_SERVER['SCRIPT_NAME']
). This constant however is used in URL generation e.g.LOGIN_URL
. It should therefore be calculated from the incoming URL.The result is all links generated which are based on
WT_SCRIPT_PATH
will take the user to a different URL root; moreover trying to set theSERVER_URL
site setting in the database causes in infinite redirect loop since Apache tries to redirect to the favoured URL and webtrees sees it does not match the file directory and tries to redirect back.This commit fixes the bug - if only for the Apache redirect case. I believe this is at least better than no fix at all.