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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:21:26+00:00 2026-06-12T01:21:26+00:00

Say I have a url like this in a php variable: $url = http://mywebsite.extension/names/level/etc/page/x;

  • 0

Say I have a url like this in a php variable:

$url = "http://mywebsite.extension/names/level/etc/page/x";

how would I automatically remove everything after the .com (or other extension) and before /page/2?

Basically I would like every url that could be in $url to become http://mywebsite.extension/page/x

Is there a way to do this in php? :s

thanks for your help guys!

  • 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-12T01:21:28+00:00Added an answer on June 12, 2026 at 1:21 am

    I think parse_url() is the function you’re looking for. You can use it to break down an URL into it’s component parts, and then put it back together however you want, adding in your own things as needed.

    As PeeHaa noted, explode() will be useful for dividing up the path.

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

Sidebar

Related Questions

Let's say I have this url: www.example.com/test.php?page=4 How do i retrieve the value of
Say currently I have url like : http://mydomain.com/showpost.php?p=123 Now I want to make it
Say I have a url like this: http://www.mysite.com/forum/board1/sub-forum/topics/123 Is there a simple way in
Let's say I have a URL like this: http://example.com/ABC How can I trap the
Say I have this url: http://site.example/dir/ In this folder I have these files: test.ascx.cs
Let's say my current URL page is http://domain.com/listing.php?term=updated&page=7&more=new-user In this page have a link
Let's say I have something like this: <?php namespace Twitter; class Twitter { function
I'm new to cakephp...and I have a page with a url this: http://localhost/books/filteredByAuthor/John-Doe so
I have a php page that returns json like this: while ($row = oci_fetch_array($stid,
Say I have the following pages: http://www.site.com/folder/page.php?id=89 http://www.site.com/folder/page.php?id=85 http://www.site.com/folder/page.php?id=camel+hump http://www.site.com/folder/page.php?id=76 http://www.site.com/folder/page.php?id=71 http://www.site.com/folder/page.php?id=frog http://www.site.com/folder/page.php?id=62 http://www.site.com/folder/page.php?id=59

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.