Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7824345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:34:03+00:00 2026-06-02T08:34:03+00:00

I am trying to write a code that takes a URL that has 3

  • 0

I am trying to write a code that takes a URL that has 3 parts (www).(domainname).(com) and trim the first part out completely.

So far I have this code that checks if on the left side I don’t have a ‘www’ or ‘dev’
go in and set siteDomainName = removecharsCGI.SERVER_NAME,1,2);

if (numHostParts eq 3 and listfindnocase('www,dev',left(CGI.SERVER_NAME,3)) eq 0) {
        siteDomainName = removecharsCGI.SERVER_NAME,1,2);

The problem with the code above is that is deleting only 2 characters where I need it to delete ALL characters until numHostParts eq 2 or at least until the first “.”

Another example would be:

akjnakdn.example.com I need the code to delete the first part of the URL with the dot included (akjnakdn.)

This code will help some of the queries that i have on the site to stop crushing because they are related with the #URL# and when the #URL# is fake I am getting cform query returned zero records error that is causing my contact forms to stop working.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T08:34:04+00:00Added an answer on June 2, 2026 at 8:34 am

    You could do something like this:

    <cfscript> 
        local.nameArr = ListToArray(CGI.SERVER_NAME, '.');
        if (ArrayLen(local.nameArr) gt 2) {
            ArrayDeleteAt(local.nameArr, 1);
        }
        siteDomainName = ArrayToList(local.nameArr, '.');
    </cfscript>
    

    I’ve split the server name into array elements with a period as the delimiter. If the number of elements is greater than two, remove the first element. Then convert it back to a list with the period as a delimiter.

    UPDATE

    As suggested by Robb, this could be more concise and perform better by skipping the array conversion process:

    <cfscript> 
        siteDomainName = CGI.SERVER_NAME;
        if (ListLen(siteDomainName, '.') gt 2) {
            siteDomainName = ListDeleteAt(siteDomainName, 1, '.');
        }
    </cfscript>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write a snippet of code that takes a URL and
I’m trying to write some encryption code that is passed through a Url .
I've been trying to write some very fast Java code that has to do
I'm trying to generate code that takes a StringBuilder, and writes the values of
I'm trying to write code that will load an image from a resource, and
I've been trying to write code that loads a .png file, attaches hotspot information,
I am trying to write some code that that will draw the line which
I'm trying to write some c++ code that tests if a string is in
I'm trying to write some Python code that will establish an invisible relay between
I'm trying to write a regular expression for html code that looks like this:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.