Questions tagged [parse-url]

url-parsing is the process of splitting a Universal Resource Locator into its component parts usually to extract parameters made as part of a request or to filter requests. The url http://parts.web.site/discount?part=51762 might be parsed to identify "/discount" and "part=51762" was requested

Overview

A Universal Resource Locator is a character string that represents an internet resource.

An example of a URL might be:

ftp://my.photo.site:21/static/photo?id=82713&format=png

url-parsing is the process of splitting a URL into its component parts, usually to retrieve request parameters or to filter requests. The example above might be parsed into:

scheme: ftp
domain: my.photo.site
port: 21
path: /static/photo
query_string: id=82713 format=png

The process of parsing a url can be managed by a library like the python urlparse, by server frameworks or string processing functions like regex.

Links

94 questions
1
vote
2 answers

How to parse URL for JSON use in Rails?

So I'm using a Venmo authentication in my Rails site. Basically the user clicks the authenticate button, and is sent to Venmo to authorize my app. Then when authorized, Venmo redirects back to my app but with the url in the format:…
blunatic
  • 325
  • 2
  • 6
  • 16
1
vote
2 answers

php return request URI from string

I have a scenario where a user can enter a web address into a text field and I need to return the URI from it. So a user could potentially enter addresses in the following state of…
1
vote
0 answers

parse_url not working properly in 5.3

I need to parse the url in php. The url starts with // is parsing correctly in php 5.5 but not in 5.3. php 5.3 does return "host" as null and it returns domain with path in "path". I am getting the url form remote site. I am also getting the url…
user3350854
  • 55
  • 1
  • 1
  • 6
1
vote
2 answers

Parsing Friendly Urls in Javascript

the website i maintain is moving from the standard php url format: http://example.com/page.php?key=value&key=value... to a more seo friendly format like this: http://example.com/page/key/value/key/value... I was using this function in javascript…
user2707535
  • 75
  • 2
  • 6
1
vote
4 answers

Add/Replace URL GET parameter depending on current URL

I’ve tried for some time now to solve what probably is a small issue but I just can’t seem get my head around it. I’ve tried some different approaches, some found at SO but none has worked yet. The problem consists of this: I’ve a show-room page…
Emil Devantie Brockdorff
  • 4,724
  • 12
  • 59
  • 76
1
vote
1 answer

PHP + Apache - Parse URL mod_rewrite

I want to use mod_rewrite with PHP, parse the URL with this format: http://www.domain.com/Path-to-index.php/Class_to_Load/Function_to_Execute/Arguments_as_array_to_the_function The class to load will be included of the directory classes, with a…
1
vote
2 answers

Compare domains that read from file in php

I have a txt file which contains domains and ips looks like this aaa.bbb.com 8.8.8.8 bbb.com 2.2.2.2 ... ... .. How do I replace bbb.com to 3.3.3.3 but do not change aaa.bbb.com? Here is part of my function, but not working at all. First part I…
tommyhsu
  • 27
  • 6
1
vote
1 answer

Convert NGINX rewrite rule to PHP

I've this NGINX rewrite URL: if ($http_host !~ "([a-zA-Z0-9.-]+)\.example\.com(.+)") { rewrite ^ http://example.com/browse.php?u=http://$1$2? permanent; } I want to convert the rule to PHP because my host does not let me change the server_name…
Ton Hoekstra
  • 55
  • 1
  • 10
1
vote
2 answers

use parse_url to get entire url instead of part of it

I was trying to make this function more comprehensive to parse more of a url Currently the function I have is this function _pagepeeker_format_url($url = FALSE) { if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) { return FALSE; } // try to…
naeluh
  • 951
  • 11
  • 17
1
vote
1 answer

how to parse url with mysql?

Mssql have a function parseURL. But we have moved our database from mssql to mysql. Mysql doesnot have parse url, Now we need to create parseURL function manually. How to create parse url function in mysql? this is mssql function ` SET…
Vahid Chakoshy
  • 1,497
  • 15
  • 27
0
votes
4 answers

Strip the last part off a url

Possible Duplicate: extract last part of a url I have a url like this: http://www.domain.co.uk/product/SportingGoods/Cookware/1/B000YEU9NA/Coleman-Family-Cookset I want extract just the product name off the end "Coleman-Family-Cookset" When I…
Ben Paton
  • 1,432
  • 9
  • 35
  • 59
0
votes
3 answers

how can PHP change a URL

I am trying to use PHP to change all dynamic URLs inside a div to a different, static URL. For example I have:
Title 123 Title 321
JB.
  • 893
  • 3
  • 16
  • 29
0
votes
2 answers

Sanitising URLS (mainly for spaces) when parsing XML iPhone

I'm parsing XML using CXML in my iphone app, works fine when the locaiton I'm searching for (using query string) is a single word. However when I add a space (Say i'm searching for shoe shop) it falls over. I tried replacing the " " space with a %20…
MissCoder87
  • 2,669
  • 10
  • 47
  • 82
0
votes
1 answer

Get query string in PHP doesn't work

I am a php newbie, and I'm trying to follow suggestions for how to get the query string. I want the words searched on in a readable format. Now, the strings come from a database, where they have been previously collected using the request object's…
Anders
  • 12,556
  • 24
  • 104
  • 151
0
votes
1 answer

Problem using parse_url() on extracted url from a csv through fgetcsv()

I do have a quite strange happening to me, and i can't seem to figure where is my problem I have a csv file I use to export datas. It's filled with urls and other stuff. I have extracted URL in this the array $urlsOfCsv I extracts csv lines into an…