Searched all questions by redirect keyword (e.g. 1, 2) but none of them fit my case.

I want to redirect my domain (www.example.com) to another (sub-)domain including path and query if possible:


I do not host second domain website and since that I have no access to its configuration.

My registrar allows setting up domain forwarding but only mirroring one:

example.com/resources/index.html -> newdomain.com/resources/index.html

and I want to set up redirect from my root directly to document.

Is there a way?

UPDATE: having in place AWS instance, what would be the most effortless way of implementing such redirect?

  • Redirecting requires a web server. It isn't possible to redirect without having some minimal amount of hosting. In other words, it isn't possible to redirect with just DNS. Commented Nov 5, 2019 at 14:22
  • Ok, and such service as Cloudflare that was mentioned? It can be useful?
    – Suncatcher
    Commented Nov 5, 2019 at 20:47
  • I also have AWS Linux instance, how to set up such redirection with minimum effort? Could you point out some documentation? Updated the question and removed no-hosting requirement
    – Suncatcher
    Commented Nov 5, 2019 at 20:48
  • You referred to both www.example.com and example.com in your question - note that these are different hostnames and consequently both will need to be configured in your AWS instance if you wish to redirect from both.
    – MrWhite
    Commented Nov 6, 2019 at 0:07
  • Use redirect.center
    – DavChana
    Commented Nov 8, 2019 at 5:44

2 Answers 2


You can use a DNS A record to point the domain to the IP address of your Linux instance. Assuming that the instance is running Apache, you would then create a virtual host that does this redirect:

<VirtualHost *:*>
    ServerName example.com
    RedirectMatch ".*" "https://www.lokki.newdomain.example/resources/index.html?crsource=google&category=web"

You don't say what Linux distribution you are running, so where this configuration needs to go can be a bit different. On Debian based distributions such as Ubuntu or Mint it would go in /etc/apache2/sites-available/example.com.conf then you would use the commands sudo a2ensite example.com and sudo service apache2 reload to enable it and load the configuration into the already running server instance.

Using Nginx, the syntax would be the following, but I'm not sure which file it would go in.

server {
  server_name .example.com;
  return 301 https://www.lokki.newdomain.example/resources/index.html?crsource=google&category=web;
  • I'm running AMI Linux, Amazon's fork of CentOS. Can nginx also be an option?
    – Suncatcher
    Commented Nov 5, 2019 at 21:08
  • Sure, Nginx can do it. I edited some config into my answer. Commented Nov 5, 2019 at 21:14
  • Thanks, I've successfully configured redirection, it works. Can you please suggest how to do so that original URL is showed in address bar (www.example.com), not target long URL? Tried proxy_pass and rewrite but that didn't work
    – Suncatcher
    Commented Nov 24, 2019 at 3:08
  • You would have to use proxy_pass across host names. However, I don't know nginx well enough to answer that. You should probably ask another question here about it. Specifically, I don't know how you would proxy all wildcard URIs to a specific page on the other server. Commented Nov 24, 2019 at 10:48
  • Ok, thanks anyway
    – Suncatcher
    Commented Nov 25, 2019 at 15:56

Cloudflare Webworkers or Nginx reverse proxy redirection could be worth a shot.

  • 2
    Such a short answer is not high quality. Can you explain how to use those? It would also be helpful to link to documentation for them. Commented Nov 5, 2019 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.