Home / Blog / Post
Proxy Traffic To Another Domain Using Htaccess
Added on 23rd July 2019 in Snippet

I am documenting this here as it was not apparent when researching this and took a while to find, hopefully this will make the answer more obvious for anyone needing it

If you want to server content from one domain on another domain, this can be achieved using mod_rewrite rules in Apache. This is done by using the [P] flag which enabled mod_rewrite to pass urls through to mod_proxy to another server.

Example

The following example will pipe all traffic from www.example1.com/example/ to www.example2.com

RewriteEngine On
RewriteRule ^/?exmaple/(.*)$ http://www.example2.com/$1 [P]

Hi there, I am christopher shaw, a software developer form South Yorkshire, England.

I love tinkering with all things tech, and opened this website as a web presence for myself and a place to keep my notes and snippets. Hopefully you will find something here to help

Christopher Shaw