SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot LSW's Avatar
    Join Date
    Jul 2004
    Location
    Juneau Alaska
    Posts
    182
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Best way to switch link Urls from localhost to WWW

    Ok, I am creating Dynamic pages. I learned PHP back in 2002 in a 6 week course and then never used it again so I am really rusty.

    Due to multiple levels, I am using my Nav List in a external sheet and linking directly to it with includes
    Code:
    http://www.blablabla.info/includes/globalNav.html
    So the obvious problem now is that to test the site it has to be
    Code:
    http://localhost/blablabla/includes/globalNav.html
    Once I am done I must use find and replace to change that back to
    Code:
    http://www.blablabla.info/includes/globalNav.html
    Now there has to be a easier way. I have considered making the
    Code:
    http://www.blablabla.info/
    section into a sperate include so
    Code:
    http://www.blablabla.info/
    sits on the server and
    Code:
    http://localhost/blablabla/
    sits on my test server.

    Now this is fine in theory, but requires placing a include inside a include wich is not the best way I believe. Course there are still requires and functions and gets......... or something like if / else to decide which to use.

    Anyone have a good suggestion for this problem? I figure there must be some easier methods than what I have come up with, I am just to rusty with PHP still.
    Thank You, Migwetth, Gunalche’esh, Ha’w'aa, Danke

    Kyle Lamson



  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,605
    Mentioned
    19 Post(s)
    Tagged
    2 Thread(s)
    Kyle,

    PHP can use relative includes, just like relative links in HTML.

    You can also use "site root" with the leading slash but that tends to fail on my test server 'cause I've got websites/sitename/httpdocs on my localhost before I get to most files.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    SitePoint Zealot LSW's Avatar
    Join Date
    Jul 2004
    Location
    Juneau Alaska
    Posts
    182
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am using includes to add common structural elements to my pages like footer, DOCTYPES and common meta tags, as well as all pages loading the same Navagation list.

    For this reason relative will not work as index is on one level, most other pages on another level and a few scattered pages on other levels, so the relative for one will not work for the others, so rather than having different versions I am using direct links on one single document.

    This however causes the www/localhost problem *sigh*. If it ain't one thing it is another.... gotta love it ! *grummel*

    Thanks for the reply
    Thank You, Migwetth, Gunalche’esh, Ha’w'aa, Danke

    Kyle Lamson



  4. #4
    SitePoint Evangelist Daijoubu's Avatar
    Join Date
    Oct 2002
    Location
    Canada QC
    Posts
    454
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just in case you were not aware of ../
    How about setting this into an constant?

    define('BASE_URL', 'http://blahblah.net/stuffs/');

    $yoururl = BASE_URL.'yourlink/stuffs.htm';

    *OR* play with Window's HOSTS file so yoursite.com loads localhost
    Speed & scalability in mind...
    If you find my reply helpful, fell free to give me a point

  5. #5
    SitePoint Zealot LSW's Avatar
    Join Date
    Jul 2004
    Location
    Juneau Alaska
    Posts
    182
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, Ok. Nope, had not thought about constants. Will give it a shot.

    Follow you with the Hosts file as well, not a bad idea as well. I have this loooooong hosts files to see that whenever M$ products try to call hoe they call themselves *grin*.

    Thanks will give both a test. Appreciate it.
    Thank You, Migwetth, Gunalche’esh, Ha’w'aa, Danke

    Kyle Lamson




Bookmarks

Posting Permissions

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