Redirect root domain to path
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:
www.lokki.newdomain.com/resources/index.html?crsource=google&category=web
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?
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"
</VirtualHost>
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;
Cloudflare Webworkers or Nginx reverse proxy redirection could be worth a shot.
Comments
Post a Comment