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 7703593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:29:41+00:00 2026-05-31T23:29:41+00:00

I have a series of Rackspace Cloud Files CDN URLs stored which reference an

  • 0

I have a series of Rackspace Cloud Files CDN URLs stored which reference an HTTP address and I would like to convert them to the HTTPS equivalent.

Rackspace Cloud Files CDN URLs are in the following format:

http://c186397.r97.cf1.rackcdn.com/CloudFiles Akamai.pdf

And the SSL equivalent for this URL would be:

https://c186397.ssl.cf1.rackcdn.com/CloudFiles Akamai.pdf

The changes to the URL are (source):

  1. HTTP becomes HTTPS
  2. The second URI segment (‘r97’ in this example) becomes ‘ssl’

The ‘r00’ part seems to vary in length (as some are ‘r6’ etc.) so I’m having trouble converting these URLs to HTTPS. Here’s the code I have so far:

function rackspace_cloud_http_to_https($url)
{
    //Replace the HTTP part with HTTPS
    $url = str_replace("http", "https", $url, $count = 1);

    //Get the position of the .r00 segment
    $pos = strpos($url, '.r');

    if ($pos === FALSE)
    {
        //Not present in the URL
        return FALSE;
    }

    //Get the .r00 part to replace
    $replace = substr($url, $pos, 4);

    //Replace it with .ssl
    $url = str_replace($replace, ".ssl", $url, $count = 1);

    return $url;
}

This however does not work for URLs where the second segment is of a different length.

Any thoughts appreciated.

  • 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-05-31T23:29:43+00:00Added an answer on May 31, 2026 at 11:29 pm

    Try this:

    function rackspace_cloud_http_to_https($url)
    {
        $urlparts = explode('.', $url);
    
        // check for presence of 'r' segment
        if (preg_match('/r\d+/', $urlparts[1]))
        {
            // replace appropriate segments of url
            $urlparts[0] = str_replace("http", "https", $urlparts[0]);
            $urlparts[1] = 'ssl';
    
            // put url back together
            $url = implode('.', $urlparts);
            return $url;
        }
        else
        {
            return false;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a series of PHP page, and I would like to use conditional
I have a series of strings (URLs) in different forms as: http://domain name.anything/anypath https://dmain
I have a series of delimited files, some of which have some bad data
I have a series of genes that I would like to associate with a
I have a series of performance tests I would like to show as a
I have a series of datetime objects and would like to calculate the average
I have a series of if statements in a function like this: if time
I have a series of... pseudo-xml files. What I mean by this, is they
I have a series like 1,2,199,100,8,100,199,1001,5,9 and I got to write a pseudo code
I have a series of queries in a stored procedure that are connected with

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.