I have a domain name: TestSite.com. I create several subdomains for this site and refer to them as first.TestSite.com, second.TestSite.com, etc.
How do I refer to TestSite.com relatively without having to hard code its name in an html or aspx file in first.TestSite.com? What I mean is (using folders as example) if I have a folder TestSite and a sub folder first
TestSite/first
, then from first I can refer to its parent TestSite folder by
../
What do I use to refer to TestSite.com from first.TestSite.com? Thanks.
There’s no way using pure relative links. You have to program it as a string manipulation.
Something like:
EDIT: Shorter version using regex:
This is general, so it will always return the last part. Regardless of whether it’s
a.TestSite.com,b.a.TestSite.com, etc. it will returnTestSite.com.You will have to modify it if this assumption is not correct.