{"id":8843,"date":"2017-02-12T00:51:25","date_gmt":"2017-02-12T00:51:25","guid":{"rendered":"https:\/\/kb.okra.host\/article\/forwarding-a-web-site-elsewhere\/"},"modified":"2021-04-06T14:42:45","modified_gmt":"2021-04-06T13:42:45","slug":"forwarding-a-web-site-elsewhere","status":"publish","type":"ht_kb","link":"https:\/\/kb.okra.host\/de\/article\/forwarding-a-web-site-elsewhere\/","title":{"rendered":"Weiterleiten einer Website an eine andere Stelle"},"content":{"rendered":"<h2 id=\"overview\" >Overview<\/h2>\n<p>A forwarded website can be accomplished by first creating a <a href=\"https:\/\/kb.apiscp.com\/web-content\/creating-subdomain\/\">subdomain<\/a> or <a href=\"https:\/\/kb.apiscp.com\/control-panel\/creating-addon-domain\/\">addon domain<\/a> in the <a href=\"https:\/\/kb.apiscp.com\/control-panel\/logging-into-the-control-panel\/\">control panel<\/a>, then using an <a href=\"https:\/\/kb.apiscp.com\/guides\/htaccess-guide\/\">.htaccess<\/a> in <a href=\"https:\/\/kb.apiscp.com\/web-content\/where-is-site-content-served-from\/\">document root<\/a>\u00a0to redirect all traffic to the new web site using <a href=\"http:\/\/httpd.apache.org\/docs\/current\/mod\/mod_rewrite.html\">mod_rewrite<\/a>.<\/p>\n<h3 id=\"important-terminology\" >Important terminology<\/h3>\n<ul>\n<li>Forwarded domain: domain that\u00a0will redirect to the target domain<\/li>\n<li>Target domain: domain that is the final destination of the forwarded domain<\/li>\n<li>Path capture: take the path in the url, e.g. <code>\/foo\/bar\/baz<\/code> in <code>http:\/\/example.com\/foo\/bar\/baz<\/code>, and transfer that path to the target domain. This is accomplished with a <a href=\"https:\/\/regexone.com\/lesson\/capturing_groups\">regex capture<\/a><\/li>\n<\/ul>\n<h3 id=\"direct-forward-no-path-capture\" >Direct Forward, No Path Capture<\/h3>\n<p>Add the following lines to your .htaccess file in the document root of the forwarded domain (or subdomain) that you would like to redirect. Once a user accesses the website, the browser location will change to reflect the target domain.<\/p>\n<p><code>RewriteEngine On<\/code><br \/>\n<code>RewriteRule ^ http:\/\/DESTINATIONSITE\/OPTIONALURL [R=301,L]<\/code><\/p>\n<h3 id=\"direct-forward-path-capture\" >Direct Forward, Path Capture<\/h3>\n<p><code>RewriteEngine On<\/code><br \/>\n<code>RewriteRule ^(.*)$ http:\/\/DESTINATIONSITE\/$1 [R=301, L]<\/code><\/p>\n<h3 id=\"proxied-forward-path-capture\" >Proxied Forward, Path Capture<\/h3>\n<p>A proxied forward will attempt to keep the original domain in the Location bar of the browser and impersonate the target site as if it were hosted under the forwarded domain. There are <strong>several limitations<\/strong> to this approach that are only resolvable by manipulating the stream as it comes over the wire, which is also beyond the scope of this\u00a0article but accomplished with reverse proxy middleware as is used in apnscp to <a href=\"https:\/\/github.com\/apisnetworks\/cp-proxy\/blob\/master\/app.js\">redirect<\/a> cp.apnscp.com to each platform&#8217;s control panel.<\/p>\n<p><code>RewriteEngine On<\/code><br \/>\n<code>RewriteRule ^(.*)$ http:\/\/DESTINATIONSITE\/$1 [<strong>P<\/strong>,L,QSA]<\/code><\/p>\n<p>A proxied forward will leak the\u00a0target domain&#8217;s location if the target domain uses absolute URLs or sends a &#8220;Location:&#8221; header as if forwarding in one of the two above examples.<\/p>\n<h2 id=\"redirect-codes\" >Redirect Codes<\/h2>\n<p>Each redirect in the aforementioned examples uses &#8220;301&#8221;. There are 4 types of redirects to familiarize yourself with, each code is pragmatic in that it instructs the browser or search engine how to handle the response:<\/p>\n<ul>\n<li><strong>301<\/strong>: Permanent redirect. Clients making subsequent requests for this resource should use the new URL. Clients should <strong>not<\/strong> follow the redirect automatically for POST\/PUT\/DELETE requests.<\/li>\n<li><strong>302<\/strong>: Redirect for undefined reason. Clients making subsequent requests for this resource should <strong>not<\/strong> use the new URL. Clients should <strong>not<\/strong> follow the redirect automatically for POST\/PUT\/DELETE requests.<\/li>\n<li><strong>303<\/strong>: Redirect for undefined reason. Typically, &#8216;Operation has completed, continue elsewhere.&#8217; Clients making subsequent requests for this resource should <strong>not<\/strong> use the new URL. Clients <strong>should<\/strong> follow the redirect for POST\/PUT\/DELETE requests.<\/li>\n<li><strong>307<\/strong>: Temporary redirect. Resource may return to this location at a later point. Clients making subsequent requests for this resource should use the old URL. Clients should <strong>not<\/strong> follow the redirect automatically for POST\/PUT\/DELETE requests.<\/li>\n<\/ul>\n<p><em>Credit: <a href=\"http:\/\/stackoverflow.com\/questions\/4764297\/difference-between-http-redirect-codes#4764456\">Bob Aman<\/a>, StackOverflow<\/em><\/p>\n<h2 id=\"see-also\" >See Also<\/h2>\n<ul>\n<li><a href=\"http:\/\/httpd.apache.org\/docs\/2.0\/misc\/rewriteguide.html\">URL Rewriting Guide<\/a>\u00a0(apache.org)<\/li>\n<li><a href=\"http:\/\/www.regular-expressions.info\/tutorial.html\">Regular Expression Tutorial &#8211; Learn How to Use Regular Expressions<\/a> (regular-expressions.info)<\/li>\n<li><a href=\"https:\/\/moz.com\/learn\/seo\/redirection\">Redirection &#8211; Best Practices<\/a> (moz.com)<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Overview A forwarded website can be accomplished by first creating a subdomain or addon domain in the control panel, then using an .htaccess in document root\u00a0to redirect all traffic to the new web site using mod_rewrite. Important terminology Forwarded domain: domain that\u00a0will redirect to the target domain Target domain: domain&#8230;<\/p>","protected":false},"author":1,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"ht-kb-category":[54],"ht-kb-tag":[],"class_list":["post-8843","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-web-content"],"_links":{"self":[{"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb\/8843","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/comments?post=8843"}],"version-history":[{"count":1,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb\/8843\/revisions"}],"predecessor-version":[{"id":8844,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb\/8843\/revisions\/8844"}],"wp:attachment":[{"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/media?parent=8843"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb-category?post=8843"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/kb.okra.host\/de\/wp-json\/wp\/v2\/ht-kb-tag?post=8843"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}