{"issue":{"state":"open","created_at":"2011-11-29T09:53:33Z","updated_at":"2011-11-29T09:53:36Z","user":{"gravatar_id":"02c8f3c5cd56551b510e61ab671abc87","id":1224532,"url":"https://api.github.com/users/jantheofel","login":"jantheofel","avatar_url":"https://secure.gravatar.com/avatar/02c8f3c5cd56551b510e61ab671abc87?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"comments":3,"body":"In system/libraries/Environment.php wird die Variable $_SERVER['REQUEST_URI'] ausgewertet um die aktuelle URL zu ermitteln. Diese berücksichtigt jedoch keine Rewrite-Regeln.\n\nBeispiel: Man möchte (wie im Forum öfters angefragt) die News-URLs ohne /items/ anzeigen lassen und setzt dazu folgende RewriteRegel: (Es ist natürlich klar, dass das alleine nicht ausreichend ist\n\n![]()\n\n```\nRewriteRule blog/(.*) /blog/items/$1\n```\n\nDiese Regel hat jedoch keine Auswirkung auf $_SERVER['REQUEST_URI']. Dadurch kann man keinerlei derartige Rewriteregeln nutzen.\n\nDaher muss man in den Rewrite-Regeln die Umgebungsvariable REQUEST_URI neu setzen, beispielsweise so:\n\n```\nRewriteRule blog/(.*) index.php [E=REQUEST_URI:/blog/items/$1,L]\n```\n\nIn diesem Fall wird aber nicht $_SERVER['REQUEST_URI'] anders gesetzt sondern $_SERVER['REDIRECT_REQUEST_URI'], siehe unten.\n\nDaher sollte in system/libraries/Environment.php der Code ab Zeile 204 wie folgt angepasst werden:\n\n```\n                if ()empty($_SERVER['REDIRECT_REQUEST_URI']))\n                {\n                        return $_SERVER['REDIRECT_REQUEST_URI'];\n                }\n                elseif (!empty($_SERVER['REQUEST_URI']))\n                {\n                        return $_SERVER['REQUEST_URI'];\n                }\n                else\n                [...]\n```\n\n```\n\nAus der Apache-Dokumentation zu diesem Thema: \"A new batch of environment variables will be initialized for use by a script which has been redirected to. Each new variable will have the prefix REDIRECT_. REDIRECT_ environment variables are created from the CGI environment variables which existed prior to the redirect, they are renamed with a REDIRECT_  prefix, i.e., HTTP_USER_AGENT becomes REDIRECT_HTTP_USER_AGENT. In addition to these new variables, Apache will define REDIRECT_URL  and REDIRECT_STATUS to help the script trace\"\nQuelle: http://httpd.apache.org/docs/2.2/custom-error.html#custom\n\n--- _Originally created on September 21st, 2010, at 04:10pm (ID 2556)_","assignee":null,"id":2382252,"labels":[{"name":"Defect","color":"bd2c00","url":"https://api.github.com/repos/contao/test/labels/Defect"},{"name":"framework","color":"e6e6e6","url":"https://api.github.com/repos/contao/test/labels/framework"}],"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"number":2556,"title":"URL Auswertung berücksichtigt keine Rewriteregeln","closed_at":null,"html_url":"https://github.com/contao/test/issues/2556","url":"https://api.github.com/repos/contao/test/issues/2556","milestone":null},"action":"created","comment":{"created_at":"2011-11-29T09:53:36Z","updated_at":"2011-11-29T09:53:36Z","user":{"gravatar_id":"02c8f3c5cd56551b510e61ab671abc87","id":1224532,"url":"https://api.github.com/users/jantheofel","login":"jantheofel","avatar_url":"https://secure.gravatar.com/avatar/02c8f3c5cd56551b510e61ab671abc87?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"Hmm, dein Design wäre damit natürlich etwas durchbrochen, aber technisch funktioniert es. Alternativ wäre die Möglichkeit einfach zusätzlich mit einzubauen:\n\n```\n        public function redirectrequest\n        {\n                $strRequest = preg_replace('/^' . preg_quote(TL_PATH, '/') . '\\/?/i', '', $this->requestUri(1));\n        [...]\n```\n\nDann könnte man statt dessen einfach diese FUnktion aufrufen, wenn man das entsprechend braucht.\n\nAus obiger Zeile wird dann:\n\n```\n$strRequest = preg_replace('/\\?.*$/i', '', $this->Environment->rewriterequest);\n```\n\n--- _Originally created on September 29th, 2010, at 09:47pm_","id":2926058,"url":"https://api.github.com/repos/contao/test/issues/comments/2926058"}}