Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Help CSS in PHP crash when putting / in the end of url.

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #165272
    geloboyet
    Participant

    So its all said in the title. REPLY asap. Thanks

    #165544
    dragon10y
    Participant

    Do this :

    <?php
    // The url var is named $url here change it if needed.
    // Change the GET var to your needs to.
    
            $url = isset($_GET['url']) ? $_GET['url'] : null;
            $url = rtrim($url, '/');
            $url = filter_var($url, FILTER_SANITIZE_URL);
            $new_url = explode('/', $url);
    ?>
    

    That should take care of the problem.

    #165602
    __
    Participant

    That should take care of the problem.

    How do you figure? The user gives us no clue whatsoever as to why their script is crashing. How can you be sure this will solve it? How do you know that this code will even run—what if it’s a parse error?


    @geloboyet
    , no, it’s not “all said in the title.” If you need further help, you need to explain your problem more clearly. Showing the relevant code will surely be helpful as well.

    #166395
    BionicClick
    Participant

    I agree, without more info… removing the forward slash only make sense.. as the OP states without it its ok… pretty straightforward…

    +1 for shaneisme for helping.

    <hr />

    explination to the OP:

    if you have a URL of say, http://example.com it visits the default page in the main folder.

    if you have a URL of say, http://example.com/ it STILL visits the default page in the main folder.

    if you have a URL of say, http://example.com/folder1/ it visits the default page in the folder named “folder1” folder. if there is not a default file in folder “folder1” then your going to get a black white page or error message.

    visiting http://example.com/folder1/ is like visiting http://example.com/folder1/index.html

    personally on my web servers the default web page is index.php, and falls back to index.html. meaning that IF I visit http://example.com/folder1/ and inside “folder1” there is a file named “index.php” on my server I see that page… if the index.php file is missing but there is a index.html file I see that instead.. but if both are missing, I get a blank white page, or an error… such as “cannot be found” or something.

    <hr />

    caveat

    IF your site fails at the following examples you have larger issues. or no default webpage file in the folder where the URL points.

    http://example.com/
    http://example.com/index.html/
    http://example.com/myFolderName/index.html/

    examples that should always fail
    http://example.com/myFolderName (with no default files in folder like index.html)
    http://example.com/myFolderName/ (with no default files in folder like index.html)
    http://example.com/myFolderName/index (with no default files in folder like index.html)
    http://example.com/myFolderName/index.

    #166399
    __
    Participant

    mygreatsite.com

    You should use the example domain (http://example.com) for examples. That’s what it’s for, after all; so you don’t accidentally link to domains you did not intend to. (I’m a mod on another forum, and I can’t tell you how many times I have to deal with posts that use xxx.com as an example…!)

    #166410
    BionicClick
    Participant

    noted, and changed. Thank you.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘Back End’ is closed to new topics and replies.