From 85f953c08713a16baa0ab2da269bc496ae49a150 Mon Sep 17 00:00:00 2001
From: Alexander Ebert <ebert@woltlab.com>
Date: Mon, 1 Jul 2013 17:31:01 +0200
Subject: [PATCH] Added ability to disable redirect if WCF is embedded

---
 .../system/request/RequestHandler.class.php   | 36 ++++++++++---------
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/wcfsetup/install/files/lib/system/request/RequestHandler.class.php b/wcfsetup/install/files/lib/system/request/RequestHandler.class.php
index b0b8e59666..40ecc3c018 100644
--- a/wcfsetup/install/files/lib/system/request/RequestHandler.class.php
+++ b/wcfsetup/install/files/lib/system/request/RequestHandler.class.php
@@ -122,24 +122,26 @@ class RequestHandler extends SingletonFactory {
 				}
 				
 				// check if accessing from the wrong domain (e.g. "www." omitted but domain was configured with)
-				$applicationObject = ApplicationHandler::getInstance()->getApplication($application);
-				if ($applicationObject->domainName != $_SERVER['HTTP_HOST']) {
-					// build URL, e.g. http://example.net/forum/
-					$url = FileUtil::addTrailingSlash(RouteHandler::getProtocol() . $applicationObject->domainName . RouteHandler::getPath());
-					
-					// add path info, e.g. index.php/Board/2/
-					$pathInfo = RouteHandler::getPathInfo();
-					if (!empty($pathInfo)) {
-						$url .= 'index.php' . $pathInfo;
-					}
-					
-					// query string, e.g. ?foo=bar
-					if (!empty($_SERVER['QUERY_STRING'])) {
-						$url .= '?' . $_SERVER['QUERY_STRING'];
+				if (!defined('WCF_RUN_MODE') || WCF_RUN_MODE != 'embedded') {
+					$applicationObject = ApplicationHandler::getInstance()->getApplication($application);
+					if ($applicationObject->domainName != $_SERVER['HTTP_HOST']) {
+						// build URL, e.g. http://example.net/forum/
+						$url = FileUtil::addTrailingSlash(RouteHandler::getProtocol() . $applicationObject->domainName . RouteHandler::getPath());
+						
+						// add path info, e.g. index.php/Board/2/
+						$pathInfo = RouteHandler::getPathInfo();
+						if (!empty($pathInfo)) {
+							$url .= 'index.php' . $pathInfo;
+						}
+						
+						// query string, e.g. ?foo=bar
+						if (!empty($_SERVER['QUERY_STRING'])) {
+							$url .= '?' . $_SERVER['QUERY_STRING'];
+						}
+						
+						HeaderUtil::redirect($url, true);
+						exit;
 					}
-					
-					HeaderUtil::redirect($url, true);
-					exit;
 				}
 			}
 			
-- 
2.20.1