---
title: "Forwarding a web site elsewhere"
date: "2017-02-12"
category: "web-content"
slug: "forwarding-web-site-elsewhere"
---

## Overview

To forward a website to another location, first create a [[creating-subdomain]] or [[creating-addon-domain]] in the [[logging-into-the-control-panel]], then use an [[htaccess-guide]] in the [[where-is-site-content-served-from]] to redirect traffic using [mod\_rewrite](http://httpd.apache.org/docs/current/mod/mod_rewrite.html).

## Key Terminology

- **Forwarded domain:** The domain that redirects visitors to the target domain.
- **Target domain:** The final destination domain.
- **Path capture:** Transfers the URL path (e.g. `/foo/bar/baz`) from the forwarded domain to the target domain using a [regex capture](https://regexone.com/lesson/capturing_groups).

## Redirect Types

### Direct Forward (No Path Capture)

Redirects all requests to a fixed URL on the target domain. Add the following to your `.htaccess` file in the forwarded domain's document root:

```
RewriteEngine On
RewriteRule ^ http://DESTINATIONSITE/OPTIONALURL [R=301,L]
```

### Direct Forward (With Path Capture)

Preserves the URL path when redirecting:

```
RewriteEngine On
RewriteRule ^(.*)$ http://DESTINATIONSITE/$1 [R=301,L]
```

### Proxied Forward (With Path Capture)

Keeps the original domain visible in the browser's address bar while serving content from the target domain:

```
RewriteEngine On
RewriteRule ^(.*)$ http://DESTINATIONSITE/$1 [P,L,QSA]
```

**Limitations:** A proxied forward will leak the target domain's URL if the target site uses absolute URLs or sends `Location` headers. Resolving this requires reverse proxy middleware, which is beyond the scope of this article.

## Redirect Codes

Each redirect example above uses a `301` code. The redirect code instructs browsers and search engines how to handle the response:

- **301**: Permanent redirect. Clients should use the new URL for future requests. Clients should not automatically follow the redirect for POST/PUT/DELETE requests.
- **302**: Temporary redirect (undefined reason). Clients should continue using the original URL. Clients should not automatically follow the redirect for POST/PUT/DELETE requests.
- **303**: See Other. Typically means "operation completed, continue elsewhere." Clients should follow the redirect for POST/PUT/DELETE requests.
- **307**: Temporary redirect. The resource may return to this location later. Clients should continue using the original URL. Clients should not automatically follow the redirect for POST/PUT/DELETE requests.

_Credit: [Bob Aman](http://stackoverflow.com/questions/4764297/difference-between-http-redirect-codes#4764456), StackOverflow_

## See Also

- [URL Rewriting Guide](http://httpd.apache.org/docs/2.0/misc/rewriteguide.html) (apache.org)
- [Regular Expression Tutorial - Learn How to Use Regular Expressions](http://www.regular-expressions.info/tutorial.html) (regular-expressions.info)
- [Redirection - Best Practices](https://moz.com/learn/seo/redirection) (moz.com)
