Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Senior Member Blackhawk095's Avatar
    Join Date
    May 2011
    Location
    Kentucky (USA)
    Posts
    384
    Member #
    27969
    Liked
    45 times
    I'm working on a tech website for my school, and I have decided to use the PHP: include function so the website will be easier to maintain. I have two include files:
    1. head.php (which holds the information in the <head> tages, the header, and the horizontal navigation)
    2. footer.php (which holds the information in the footer)


    My problem is with the files in sub-folders. When I include "head.php", the links to the css files, images, and other pages are incorrect and won't work.

    I tried using the direct url to the files. It did work, but I don't like the idea of having the file urls out for everyone to see in the source code.

    Is there a more secure way to do this?
    [COLOR=rgb(0, 51, 102)]Student Web Designer[/COLOR]
    [COLOR=rgb(0, 51, 102)]If you thought something I said was helpful. LIKE IT![/COLOR]

  2.  

  3. #2
    Senior Member Ganners's Avatar
    Join Date
    Feb 2011
    Location
    United Kingdom
    Posts
    415
    Member #
    27007
    Liked
    92 times
    You should have the full file url's really, having them relative won't reap any benefits for the public. Fact is I could save as on your page and it will change every link to include the full URL.

    You also have to remember that your images will be relative to your file containing the includes. The includes, for a way to think of it, just sort of paste the PHP into your original file.
    Mark Gannaway Software Developer

    Recent Experiments
    - Backpropogation Neural Network language solving (http://ann.ganners.co.uk/)
    - Animated image to ASCII (http://google.ganners.co.uk/)
    - 3D Paper Characters (http://cybergame.ganners.co.uk/)
    - Anagram solving (http://roflol.co.uk/)

  4. #3
    WDF Staff George Dolidze's Avatar
    Join Date
    Apr 2011
    Location
    Irvine, CA
    Posts
    2,487
    Member #
    27540
    Liked
    416 times
    You can do: ../images/background.png for example. Then it won't matter in which folder the PHP is in. Direct URLs could get annoying somethimes, when you switch domains/filenames.
    My freelancer website: DolidzeDesign



    You only need a parachute if you plan on skydiving twice.

  5. #4
    Senior Member Ganners's Avatar
    Join Date
    Feb 2011
    Location
    United Kingdom
    Posts
    415
    Member #
    27007
    Liked
    92 times
    But that's where having a global config variable like

    $site_url = "http://example.com";

    will come in useful. Then when linking to an image, css, js etc just do like

    src="<?= $site_url ?>/images/logo.jpg"
    Mark Gannaway Software Developer

    Recent Experiments
    - Backpropogation Neural Network language solving (http://ann.ganners.co.uk/)
    - Animated image to ASCII (http://google.ganners.co.uk/)
    - 3D Paper Characters (http://cybergame.ganners.co.uk/)
    - Anagram solving (http://roflol.co.uk/)

  6. #5
    Senior Member Blackhawk095's Avatar
    Join Date
    May 2011
    Location
    Kentucky (USA)
    Posts
    384
    Member #
    27969
    Liked
    45 times
    Ok. Thanks
    [COLOR=rgb(0, 51, 102)]Student Web Designer[/COLOR]
    [COLOR=rgb(0, 51, 102)]If you thought something I said was helpful. LIKE IT![/COLOR]

  7. #6
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,717
    Member #
    5580
    Liked
    718 times
    I don't know what you mean by "file URLs" ...

    You can never hide CSS or Javascript files, no matter what you do.
    Is that what you're talking about?

    If you're talking about files like PDF, images ... those paths and filenames can be hidden.

    .



Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 08:15 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com