I'm working with multiple domain names and I want to set it up so that when someone visits the root of one domain, they get redirected to another domain. However, if they access a specific path, I want it to still lead them to the original domain. For instance, I want 'name.net' to redirect to 'name.com', 'name.net/' to also redirect to 'name.com', but 'name.net/foo' should stay as 'name.net/foo'. How can I achieve this?
2 Answers
If you’re using Apache, you can set this up with a few rewrite rules. Just add the following to your .htaccess file:
```apache
RewriteEngine On
# Redirect only the root request
RewriteRule ^$ https://name.com/ [R=301,L]
```
This way, only the root requests will redirect while keeping the paths intact.
You can't handle this purely at the DNS level, as DNS is just for resolving domain names to IP addresses. It doesn't deal with URL paths, so you’ll need to configure your web server for that kind of redirection.

Related Questions
How to Build a Custom GPT Journalist That Posts Directly to WordPress
Cloudflare Origin SSL Certificate Setup Guide
How To Effectively Monetize A Site With Ads