Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Sep 2010
    Location
    London, UK
    Posts
    169
    Thanks
    28
    Thanked 0 Times in 0 Posts

    How do you extract part of a URL and use the leftover ...?

    Hi,

    Looking through my site stats via webalizer I noticed I get about 4,000 code 404 errors a month. I installed a script on the site that would email me and notify me what pages were being requested that would cause the 404 error code.

    The majority of the error codes were being generated by this type of request:

    PHP Code:
     http://matrixfiles.com/external.html?link=http://www.bollyn.com/index.php?id=11077&print=1 
    The important thing I found out was that the URL after the
    link=
    bit actually worked.

    So what I am trying to do is to find a snippet of code that I can plug into the
    external.html
    page that would strip out
    leaving
    to be passed to the browser.

    I came across this question and example code
    Question: How to trim a part of a string, and save it in a particular string in MySQL using PHP?
    Example:
    If a string has the value "REGISTER 11223344 here"
    How can I cut "11223344" from the string?
    One of the answers given was
    PHP Code:
    $string 'REGISTER 11223344 here';  $content preg_replace('/REGISTER(.*)here/','',$string); 
    Can I use this somehow to strip out the unwanted part of the URL? If so, how is the code to be written for my problem to be solved?

    Not an expert on PHP so would much appreciate the help and so would 4,000 other users

  • #2
    Regular Coder Custard7A's Avatar
    Join Date
    Jul 2010
    Location
    Australia
    Posts
    286
    Thanks
    32
    Thanked 33 Times in 33 Posts
    Sorry if I'm missing something, but isn't the value you want already assigned to the "link" variable? So if you're redirecting through that page immediately headers might work.

    external.html (I assume you are parsing PHP in html files?)
    PHP Code:
    <?php header (Location$_GET['link']); ?>
    .. Otherwise, if that page does other things that already send headers, you could put it in a meta redirect, or a Javascript redirect, but the value you want should be right there in $_GET['link'].

  • #3
    Regular Coder
    Join Date
    Sep 2010
    Location
    London, UK
    Posts
    169
    Thanks
    28
    Thanked 0 Times in 0 Posts
    external.html does not exist and I have no idea how it is being called with the rest of the link, so what I want to do is create one with the php code in it to take out the part of the url that makes the link bad.


    If you are confused just try the link in full and then the bit after the
    Code:
    link=
    One thing that might be going on is that the bit after the link= part is a mirorred site that was ripped, with the site owners permission, by httrack and this site was then placed on my servers. There may be a problem with the way the site was ripped, but I would rather find a solution instead of either re-ripping the site or going over 5,000 pages and changing the code by hand.
    Last edited by judgedredd; 10-28-2012 at 06:08 AM.

  • #4
    Regular Coder
    Join Date
    Sep 2010
    Location
    London, UK
    Posts
    169
    Thanks
    28
    Thanked 0 Times in 0 Posts
    Is anyone able to help here?

  • #5
    Regular Coder Custard7A's Avatar
    Join Date
    Jul 2010
    Location
    Australia
    Posts
    286
    Thanks
    32
    Thanked 33 Times in 33 Posts
    Is your domain "http://matrixfiles.com/", or "http://www.bollyn.com/"?

  • #6
    Regular Coder
    Join Date
    Sep 2010
    Location
    London, UK
    Posts
    169
    Thanks
    28
    Thanked 0 Times in 0 Posts
    My domain is http://matrixfiles.com

    I want the bollyn.com website, and anything after bollyn.com, passed to the browser.
    Last edited by judgedredd; 10-30-2012 at 02:45 AM.

  • #7
    Regular Coder Custard7A's Avatar
    Join Date
    Jul 2010
    Location
    Australia
    Posts
    286
    Thanks
    32
    Thanked 33 Times in 33 Posts
    So, can't you just create the page external.html and make it <?php header (Location: "\'". $_GET['link'] ."\'"); ?> or something? That should send anyone who views such a request on to the "link" part of the link, providing of course that all these requests are sent through external.html. Since you don't even know how that is being called the whole issue seems a bit trippy.
    Last edited by Custard7A; 10-30-2012 at 03:02 AM. Reason: Typo

  • #8
    Regular Coder
    Join Date
    Sep 2010
    Location
    London, UK
    Posts
    169
    Thanks
    28
    Thanked 0 Times in 0 Posts
    I tried that and it didn't work.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •