SitePoint Sponsor

User Tag List

Results 1 to 22 of 22

Thread: Absolute Path Differences

  1. #1
    SitePoint Zealot
    Join Date
    Dec 2005
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Absolute Path Differences

    Hello,

    This is probably a very basic question but it has bothered me for a while for making web sites. I develop sites initially locally before uploading them to a web hosting service. When I do file includes such as including a header, for images or css stylesheets to show on the localhost, I have to do a relative path such as ../css/style.css or it doesn't show up. Same for images. But on the host, I can have /css.style.css and it works fine in all folders.

    My question is this, is there some setting in the configuration files that I can do something to so that I can keep the same files on both localhost and web host? So that I could have /css/style.css for all cases.

    Also, I have always used a <base> reference (with an if/else statement to determine the base) in the past. However, the current site I am working on needs SSL and it throws up a message stating that some items on the page are not secure because of it. That's why I am trying to get away from the <base> reference.

    Thanks for any suggestions.

  2. #2
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,656
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Depends on what program you are running locally. I usually use dreamweaver, and you can set up a site with a root. I think if you are using xampp, /style.css it digs too far. I think there is a setting somewhere...
    Ryan B | My Blog | Twitter

  3. #3
    Web Professional
    Join Date
    Oct 2008
    Location
    London
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Relative paths are relative to the document root. Are you running a web server on your local machine?

  4. #4
    SitePoint Zealot
    Join Date
    Dec 2005
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's xampp. Just not sure where to find the setting. I am been trying different things but no luck.

  5. #5
    Web Professional
    Join Date
    Oct 2008
    Location
    London
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How do you access the local site? is it localhost? Or localhost/example/

  6. #6
    SitePoint Zealot
    Join Date
    Dec 2005
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have to access it as localhost/xampp/example.

  7. #7
    Web Professional
    Join Date
    Oct 2008
    Location
    London
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    We're almost there. Last question, I promise.
    What operating system?

  8. #8
    SitePoint Zealot
    Join Date
    Dec 2005
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Windows Vista

  9. #9
    Web Professional
    Join Date
    Oct 2008
    Location
    London
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by affmark View Post
    Windows Vista
    OK, you need to find your hosts file. It's probably in C:\windows\system32\drivers\etc\

    When you find it, open it and copy the contents and paste them here.

  10. #10
    SitePoint Zealot
    Join Date
    Dec 2005
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Paul, there's not much to it:

    Code:
    # Copyright (c) 1993-2006 Microsoft Corp.
    #
    # This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
    #
    # This file contains the mappings of IP addresses to host names. Each
    # entry should be kept on an individual line. The IP address should
    # be placed in the first column followed by the corresponding host name.
    # The IP address and the host name should be separated by at least one
    # space.
    #
    # Additionally, comments (such as these) may be inserted on individual
    # lines or following the machine name denoted by a '#' symbol.
    #
    # For example:
    #
    #      102.54.94.97     rhino.acme.com          # source server
    #       38.25.63.10     x.acme.com              # x client host
    
    127.0.0.1       localhost
    ::1             localhost

  11. #11
    Web Professional
    Join Date
    Oct 2008
    Location
    London
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's OK, there doesn't have to be much. The line that says:

    Code:
    127.0.0.1       localhost
    maps localhost to your own machine. Now, after this you can add more hostnames which will point to your own machine (separate them with a space):

    Code:
    127.0.0.1       localhost mywebsite
    Replace mywebsite with something that will represent the website you're working on.

    When you've done this, that string used as a hostname will refer to your own machine. That's what you want.

    Do that, open up your browser, use the address you've created and you should see XAMPP's welcome page. Then we'll proceed to setting up XAMPP to recognise this hostname and serve your site.

  12. #12
    SitePoint Zealot
    Join Date
    Dec 2005
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, it's done. Sorry it took so long, had to jump through some permissions hoops

    I have the xampp welcome page.

  13. #13
    Web Professional
    Join Date
    Oct 2008
    Location
    London
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Go to your xampp folder; from there go to apache/conf/extra/ and open httpd-vhosts.conf. Open that, copy the contents, paste them here.

  14. #14
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,656
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    // sidenote
    Paul is this like setting up a virtual host or different?

    Your post answered it
    Ryan B | My Blog | Twitter

  15. #15
    SitePoint Zealot
    Join Date
    Dec 2005
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here goes:

    Code:
    #
    # Virtual Hosts
    #
    # If you want to maintain multiple domains/hostnames on your
    # machine you can setup VirtualHost containers for them. Most configurations
    # use only name-based virtual hosts so the server doesn't need to worry about
    # IP addresses. This is indicated by the asterisks in the directives below.
    #
    # Please see the documentation at 
    # <URL:http://httpd.apache.org/docs/2.2/vhosts/>
    # for further details before you try to setup virtual hosts.
    #
    # You may use the command line option '-S' to verify your virtual host
    # configuration.
    
    #
    # Use name-based virtual hosting.
    #
    ##NameVirtualHost *:80
    
    #
    # VirtualHost example:
    # Almost any Apache directive may go into a VirtualHost container.
    # The first VirtualHost section is used for all requests that do not
    # match a ServerName or ServerAlias in any <VirtualHost> block.
    #
    ##<VirtualHost *:80>
    ##    ServerAdmin webmaster@dummy-host.example.com
    ##    DocumentRoot /www/docs/dummy-host.example.com
    ##    ServerName dummy-host.example.com
    ##    ServerAlias www.dummy-host.example.com
    ##    ErrorLog @rel_logfiledir@/dummy-host.example.com-error_log
    ##    CustomLog @rel_logfiledir@/dummy-host.example.com-access_log common
    ##</VirtualHost>
    
    ##<VirtualHost *:80>
    ##    ServerAdmin webmaster@dummy-host2.example.com
    ##    DocumentRoot /www/docs/dummy-host2.example.com
    ##    ServerName dummy-host2.example.com
    ##    ErrorLog @rel_logfiledir@/dummy-host2.example.com-error_log
    ##    CustomLog @rel_logfiledir@/dummy-host2.example.com-access_log common
    ##</VirtualHost>

  16. #16
    Web Professional
    Join Date
    Oct 2008
    Location
    London
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, you're setting up a virtual host. Add this to the file:

    Code:
    <VirtualHost *:80>
    	DocumentRoot "C:/path/where/your/site/lives"
    	ServerName whatever_you_ve_added_to_hosts_file
    </VirtualHost>
    Let me know how it goes. You need to restart Apache after this point, by the way.

  17. #17
    From space with love SitePoint Award Recipient SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    4,270
    Mentioned
    54 Post(s)
    Tagged
    0 Thread(s)
    Have you set the include path in the php,ini to point to the right place(s)? The section in the php.ini will look like:

    ;;;;;;;;;;;;;;;;;;;;;;;;;
    ; Paths and Directories ;
    ;;;;;;;;;;;;;;;;;;;;;;;;;

    ; UNIX: "/path1:/path2"
    ;include_path = ".:/php/includes"
    ;
    ; Windows: "\path1;\path2"
    include_path = ".;c:\php\includes;c:\php\example"

    Add one for each web app, separating them with a ;
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  18. #18
    Web Professional
    Join Date
    Oct 2008
    Location
    London
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SpacePhoenix View Post
    Have you set the include path in the php,ini to point to the right place(s)? The section in the php.ini will look like:

    ;;;;;;;;;;;;;;;;;;;;;;;;;
    ; Paths and Directories ;
    ;;;;;;;;;;;;;;;;;;;;;;;;;

    ; UNIX: "/path1:/path2"
    ;include_path = ".:/php/includes"
    ;
    ; Windows: "\path1;\path2"
    include_path = ".;c:\php\includes;c:\php\example"

    Add one for each web app, separating them with a ;
    It's got nothing to do with client's requests, which is the issue here.

  19. #19
    SitePoint Wizard rguy84's Avatar
    Join Date
    Sep 2005
    Location
    Durham, NC
    Posts
    1,656
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by decowski View Post
    Code:
    <VirtualHost *:80>
    	DocumentRoot "C:/path/where/your/site/lives"
    	ServerName whatever_you_ve_added_to_hosts_file
    </VirtualHost>
    Was trying to do this a few days ago actually, if you want to save it in My Docs, does it have issues with spaces
    Ryan B | My Blog | Twitter

  20. #20
    SitePoint Zealot
    Join Date
    Dec 2005
    Posts
    119
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Paul, you're the man!

    I can't tell you how much I appreciate this! I have fought with this for the entire time that I have been making sites. You have no idea how much I appreciate your time. You're help has been invaluable!

    God bless!

    Oh, in case you can't tell, it worked!!!!!!!!!!!!!!!!!!

  21. #21
    Web Professional
    Join Date
    Oct 2008
    Location
    London
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rguy84 View Post
    Was trying to do this a few days ago actually, if you want to save it in My Docs, does it have issues with spaces
    I wish I could know all the answers. My answer to this is don't use spaces. I'm no Windows nor Linux specialist. I stick to the rules that make the experience with both systems platforms the same: use lowercase and don't use spaces.

  22. #22
    Web Professional
    Join Date
    Oct 2008
    Location
    London
    Posts
    862
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by affmark View Post
    Thanks Paul, you're the man!

    I can't tell you how much I appreciate this! I have fought with this for the entire time that I have been making sites. You have no idea how much I appreciate your time. You're help has been invaluable!

    God bless!

    Oh, in case you can't tell, it worked!!!!!!!!!!!!!!!!!!
    So you get the idea how to set up your new killer app on your localhost? If you do then I'm done here

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
  •