Bulk Redirecting Domain Names

Azstats

Registered
Nov 29, 2006
2
0
151
Hi,

Need advice.

I am setting up an online shop selling domain names.

Each domain name will redirect to its product page.

So, if the shop URL is example.com and the product1 is domainname1.com, then it should forward (catchall, all its subdomains, urls etc.) to example.com/products/domainname1.

And domainname2.com should forward to example.com/products/domainname2 etc.

And I should be able to upload thousands of domains into my redirect setup and all of them should automatically go to the page by the above pattern.

So, is it possible with cpanel?

Thank you beforehand.
 
Last edited by a moderator:

cPanelMichael

Technical Support Community Manager
Staff member
Apr 11, 2011
47,749
2,206
363
cPanel Access Level
DataCenter Provider
Twitter
Hello @Azstats,

Is this part of an integration with an application such as WordPress (e.g. the WordPress Multi-site feature), or are you developing your own custom application?

Also, are you attempting to have the domain name (e.g. domainname1.tld) displayed in the browser address bar, or do you want access attempts to "domain1.tld" to result in "example.tld/products/domain1.tld" appearing in the address bar?

Thank you.
 

Azstats

Registered
Nov 29, 2006
2
0
151
Michael, thank you.

Yes, we will be using wordpress, but not a multisite. There is just one site, the shop. The domains are the products, so each of them would forward to their respective page, they are redirects, not aliases.

And, no masking, simple forward to the product page.

What I see in my cpanel is just redirect one at a time option. It also won't provide a catchall, for example, if someone is typing in domain1.com or domain1.com/page5 or www.domain1.com, it should all still forward to example.com/products/domainname1
 

cPanelMichael

Technical Support Community Manager
Staff member
Apr 11, 2011
47,749
2,206
363
cPanel Access Level
DataCenter Provider
Twitter
Hello @Azstats,

You'll need to first add the additional domain as Addon Domain. Then, you'll need to setup the wildcard redirect for the addon domain using one of the following methods:

1. https://documentation.cpanel.net/display/82Docs/Redirects

Redirect all files within a directory to the same filename in the new directory.
2. If the default wildcard redirect feature doesn't extend to the specific redirect rules you require, then you'll need to create custom redirect rules in the .htaccess file of the Addon domain's document root. Here's a third-party URL with some examples you can explore:

.htaccess redirect all pages to new domain

Additionally, you may find the following tutorials helpful when automating this task in the future:

Tutorial - How to Setup Standardized Hooks with BASH in cPanel & WHM
Tutorial - How To Automatically Install WordPress On New Accounts

The specific examples in the tutorial are not applicable to your use case, but the overall concept of automating actions (e.g. the addition of a redirect) through hooks may interest you.

Thank you.