/    Sign up×
Community /Pin to ProfileBookmark

How to do URL forwarding according to Level 3 domain names?

The webdevelper presets: type-in keyword subdomains = parts of the forwarded URLs
For example:
subdomain name “toy” = “noun-1” part of the forwarded URLs  
subdomain name ”food”= “noun-2” part of the forwarded URLs  
number of pre defined noun should be unlimited  
any undefined noun = “noun-0”
subdomain name “my” = “whose-1” part of the forwarded URLs
subdomain name “your” = “whose-2”part of the forwarded URLs
subdomain name “his” = “whose-3”part of the forwarded URLs
number of pre defined possessive pronoun should be unlimited
any undefined possessive pronoun = “whose-0”

So that domain names such as “[url]http://toy.website.com”[/url] and “[url]http://food.website.com”[/url] could be forwarded to some predefined URLs.

“[url]http://toy.website.com”[/url] could be forwarded to “http://www.myplace.com/noun-1-whose-0” (“noun-1” first, then ”whose-0”) “http://food.website.com” could be forwarded to “http://www.myplace.com/noun-2-whose-0

If we type in “[url]http://my.toy.website.com”[/url], it could be forwarded to “http://www.myplace.com/noun-1-whose-1
http://your.food.website.com” needs to redirect to “http://www.myplace.com/noun-2-whose-2

“[url]http://my.website.com”[/url] to “http://www.myplace.com/noun-0-whose-1
http://your.website.com” to “http://www.myplace.com/noun-0-whose-2” (“noun-0”should be in place)

If we type in some undefined words, for example, “http://undefined_whose.toy.website.com” should be forwarded to “http://toy.website.com” [just drop undefined words], then forward again to “http://www.myplace.com/noun-1-whose-0” accordingly.

“http://my.undefined_noun.website.com” first to “http://my.website.com” then to “http://www.myplace.com/noun-0-whose-1

If we only type-in level 2 subdomains without level 3 subdomains, such as “http://undefined_words.website.com” , or type in more than level 4 subdomains, or type in “both undefined level 3 and undefined level 2” ,such as “http://undefined_whose.undefined_noun.website.com” they should be redirected uniformly to “http://www.myplace.com/domain_rule.html

Could we use html5 JavaScript, get domain names from the browser to a string, use “split()” [ “ . ”as seperator, “howmany” to get number of subdomains] , then apply “if else” or “case” ?
Or php code?

Anyone could offer a lending hand and post all codes that I am able to use directly?

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @cuizeng247 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...