Redirects
This commit is contained in:
@ -194,8 +194,21 @@ bool connection_handler(const char *preprefix, const char *col1, const char *col
|
|||||||
pid_t childpid = 0;
|
pid_t childpid = 0;
|
||||||
|
|
||||||
|
|
||||||
if ((host == "necronda.net" || socket->getSocketPort() != 443) && path.getRelativeFilePath().find("/.well-known/acme-challenge/") != 0) {
|
bool redir = true;
|
||||||
|
if (path.getRelativeFilePath().find("/.well-known/acme-challenge/") != 0) {
|
||||||
|
if (host == "necronda.net") {
|
||||||
req.redirect(303, "https://www.necronda.net/");
|
req.redirect(303, "https://www.necronda.net/");
|
||||||
|
} else if (socket->getSocketPort() != 443) {
|
||||||
|
req.redirect(303, "https://" + host + req.getPath());
|
||||||
|
} else if (getWebRoot(host) == "") {
|
||||||
|
req.redirect(303, "https://www.necronda.net" + req.getPath());
|
||||||
|
} else {
|
||||||
|
redir = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (redir) {
|
||||||
|
|
||||||
} else if (!path.getNewPath().empty() && req.getMethod() != "POST") {
|
} else if (!path.getNewPath().empty() && req.getMethod() != "POST") {
|
||||||
req.redirect(303, path.getNewPath());
|
req.redirect(303, path.getNewPath());
|
||||||
} else {
|
} else {
|
||||||
|
@ -191,14 +191,11 @@ string read_line(FILE* file) {
|
|||||||
#include "../CppNet/src/network/http/HttpConnection.cpp"
|
#include "../CppNet/src/network/http/HttpConnection.cpp"
|
||||||
|
|
||||||
string getWebRoot(string host) {
|
string getWebRoot(string host) {
|
||||||
if (host == "www.necronda.net") {
|
|
||||||
host = "www.necronda.net-new";
|
|
||||||
}
|
|
||||||
string root = webroot + host;
|
string root = webroot + host;
|
||||||
if (fileExists(root)) {
|
if (fileExists(root)) {
|
||||||
return root;
|
return root;
|
||||||
} else {
|
} else {
|
||||||
return (string) webroot + "www.necronda.net-new";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user