• JS

    (@jsylvia90)


    Hello,

    I have an issue that has just developed. I hope I can explain it clearly
    and that someone may be able to assist or offer suggestions.

    I have a main domain in this account that points to a wordpress site.

    townieoriginal.com & https://www.townieoriginal.com
    townieoriginals.com & https://www.townieoriginals.com
    towniebug.com & https://www.towniebug.com

    direct to:
    https://www.townieoriginals.com/

    The above is correct with no issues.

    However, I also have a few domain aliases that are supposed to redirect
    to a sub-directory that contain html sites for their respective alias.

    I previously was using a JavaScript code in the head of my the home page
    of the WordPress site and it was working until recently for an unknown reason and I had since removed the coding.

    I also tired tinkering with the .htaccess site in the root directory of
    the site, but am not proficient with the .htaccess coding. I also tried
    to find a WordPress plugin for this without luck (came close but not for this particular scenario).

    I am to try and achieve the domain alias redirect as explained below:

    *****
    townieink.com & https://www.townieink.com
    townieplacemats.com & townieplacemats.com

    should redirect to:
    https://www.townieink.com/townieink/payment.htm
    *****

    and

    *****

    antoniosnewbedford.com & https://www.antoniosnewbedford.com

    should redirect to:
    https://www.antoniosnewbedford.com/antoniosnewbedford/

    *****

    I’ve spent several hour searching for a solution and wonder if you may
    have recommendations.

    Thanks,
    Jacquie

    The mentioned javascript code (no longer working) is:

    `<script language = “JavaScript”>
    <!–
    //***** Name this script “index.html”
    var requestedDomainObj = document.URL;
    var requestedDomain = requestedDomainObj.toLowerCase();
    var sendToLocation = “”;
    var gotMatch = false;
    var siteToCheckFor = “”;
    siteToCheckFor = /townieink.com/;
    if ((siteToCheckFor.test(requestedDomain)) && (gotMatch == false)) {
    sendToLocation = “https://www.townieink.com/townieink/payment.htm&#8221; ;
    gotMatch = true;
    }
    siteToCheckFor = /www.towniink.com/;
    if ((siteToCheckFor.test(requestedDomain)) && (gotMatch == false)) {
    sendToLocation = “https://www.townieink.com/townieink/payment.htm&#8221; ;
    gotMatch = true;
    }
    siteToCheckFor = /townieplacemats.com/;
    if ((siteToCheckFor.test(requestedDomain)) && (gotMatch == false)) {
    sendToLocation = “https://www.townieink.com/townieink/payment.htm&#8221; ;
    gotMatch = true;
    }
    siteToCheckFor = /www.townieplacemats.com/;
    if ((siteToCheckFor.test(requestedDomain)) && (gotMatch == false)) {
    sendToLocation = “https://www.townieink.com/townieink/payment.htm&#8221; ;
    gotMatch = true;
    }
    siteToCheckFor = /antoniosnewbedford.com/;
    if ((siteToCheckFor.test(requestedDomain)) && (gotMatch == false)) {
    sendToLocation =
    https://www.antoniosnewbedford.com/antoniosnewbedford/&#8221; ;
    gotMatch = true;
    }
    siteToCheckFor = /www.antoniosnewbedford.com/;
    if ((siteToCheckFor.test(requestedDomain)) && (gotMatch == false)) {
    sendToLocation =
    https://www.antoniosnewbedford.com/antoniosnewbedford/&#8221; ;
    gotMatch = true;
    }
    if (gotMatch == false) {
    sendToLocation = “/”;
    }

    if (sendToLocation != “/”) {
    window.location=sendToLocation;
    }
    //–>
    </script>

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi @jsylvia90,

    I previously was using a JavaScript code in the head of my the home page
    of the WordPress site and it was working until recently for an unknown reason and I had since removed the coding.

    Were you able to do any troubleshooting while the code was in place? Specifically wondering if you were able to observe an JavaScript errors.

    Also could I ask what method you were using to place this script on your site?

    I wouldn’t have thought that using .htaccess for this would necessarily be the best choice here, as each time you wanted to make changes you’d need to re-edit .htaccess which could cause other issues for your site.

    Have you considered taking a different approach all together here? If you have access to those domains, i.e. are registered to you, you can normally edit the DNS settings to redirect them directly to the desired URL.

    For example, updating all the “A records” for townieink.com, and replacing “216.36.247.44” with “https://www.townieink.com/townieink/payment.htm&#8221;, should automatically send traffic in that direction before even reaching your site.

    Hope that helps,

    Thanks,

    Thread Starter JS

    (@jsylvia90)

    Thanks. The JavaScript was placed in the head of the homepage. It was working with the WordPress until a recent server upgrade. My support is checking it out. I did try editing the Domain Name registration using their domain forwarding tool but that ended up giving a redirect loop error. However, didn’t touch the A records. If my support can’t fix that I will give your suggestion a try.

    Ah yes, it will have done as you are pointing to the same domain.

    I think I have found the underlying issue, are you sure you are pointing those redirects to the right pages?

    https://www.townieink.com/townieink/payment.htm
    https://www.antoniosnewbedford.com/antoniosnewbedford/

    These two URLs ^^ don’t seem to go anywhere, I just get “File Not Found” when visiting either.

    Going to either
    https://www.townieink.com/
    https://www.antoniosnewbedford.com/

    I just get “Site under construction”.

    However if I visit:
    https://www.townieoriginals.com/townieink/payment.htm
    https://www.townieoriginals.com/antoniosnewbedford/

    I get two pages that look like they could be the right pages for a redirect?

    So, I am surmising:

    1. Your “server upgrade”, whatever that entailed, changed the URLs of the destination pages. It’s difficult to understand what could have led to this without understanding a lot more about the previous and current set up.

    2. To resolve this you can either:
    – Ask whoever did your server upgrade to resolve this and replace the script
    – Update the destination URLs in the scripts to the working URLs I have listed and replace the script
    – Add domain redirects in DNS to the new working URLs I have given

    If you don’t have a need to do a), then I suggest you do c) rather than relying in JavaScript to handle such permanent redirections.

    Hope this helps,

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘domain name alias separate html site in sub directory’ is closed to new replies.