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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:57:16+00:00 2026-05-15T13:57:16+00:00

Lets say the url is http://example.com/product/3 and I only want to retrieve what is

  • 0

Lets say the url is http://example.com/product/3 and I only want to retrieve what is after http://example.com/product/. I found this, it echos the domain but how do I get the three. Its this method reliable? I’m using codeIgniter also.

<?php
function curPageURL() {
$pageURL = 'http';
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
?>

<?php
echo curPageURL();
?>
  • 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-15T13:57:17+00:00Added an answer on May 15, 2026 at 1:57 pm

    Yes, use the URI class of the codeigniter API.

    The base_url is segment zero, so in your case, products would be segment 1 and the id segment 2.

    $product_id = $this->uri->segment(2)
    

    As chetan mentioned this is clearly documented in the user guide.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say my URL is: http://www.example.com/news/media-centre/news/17/an-example-news-post/?foo=bar I want to in PHP remove the last
Let's say I have this url: www.example.com/test.php?page=4 How do i retrieve the value of
Let's say I have a referral URL http://www.example.com/r?ref=86745348 and I want to completely hide
I have a URL, lets say http://www.example.com . Sometimes, I need to send HTTP
Let's say I have a URL: http://example.com/person/list This website will display a list of
For this example lets say I want to validate a google plus profile URL
Let's say I have a URL like this: http://example.com/ABC How can I trap the
lets say that we are studding a url string: http:/domain.com/en/#the-file.html/section-4 where i have codified:
Lets say that I want to show http://example.com/topic/view/topicname/thenameofthetopic direclty as http://example.com/thenameofthetopic So I have
Let's say my URL is this: http://example.com/forum/index.php?topic=53.msg251#msg251 This part here, I can't figure out

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.