How to Completely Redirect Whole Request (With Path and Query String) From One Domain to Another?

2018-02-28 htaccess

Let’s assume your full name is Billy Example and you’re lucky enough to be owner of the following domains:

  • (why not)

You want to use as the main domain and point all other domains to the main one. By saying “point to” I mean redirect absolutely every GET request with any combination of paths and query strings.

For example:

What user requested Where user will land

All requests from each domain you own will be piped to the main one without loosing the request context. To achieve this all you need to do is to create .htaccess file and put it into public_html (or similar directory) on your hosting server for each of the domain that should redirect.

RewriteEngine on
RewriteRule ^(.*)$$1 [R=301,L]