There are so many ways to make your scripts smart enough to not need this.

You can figure out the running directory of the script, you can manually specify the home directory of your site at the top of each php file or in a global php file, you can simply tell him not to lead off directories with a /.

    That's the point, I don't want to have to include anything into each page, and when you get crazy with directories and want to hop over to another one real quick, it's far easier to type:

    /images/blah.gif

    instead of trying to figure out where you are in the structure:

    ../../../images/blah.gif

    I figured a RewriteBase or something in .htaccess would handle this but I can't find what I'm hoping for.

      sigh

      It's really not that bad to put require('global.php'); at the top of each page. I'm kinda surprised each of your pages doesn't have a unified header anyway. Ideal design is to have a header and footer for each page so you can change this in one place and it affects all the pages.

        Originally posted by feldon23
        sigh

        It's really not that bad to put require('global.php'); at the top of each page. I'm kinda surprised each of your pages doesn't have a unified header anyway. Ideal design is to have a header and footer for each page so you can change this in one place and it affects all the pages.

        Perhaps.... it'd be nice to find a solution that accommodates both static (HTML) and PHP files though. No includes or other BS, just one handy .htaccess file in the main directory.

          Back to the original post, the one about wanting

          www.domain.com/folder/images/test.jpg

          www.domain.com/images/test.jpg

          The first version has problems with name collisions. If you have:

          www.domain.com/folder1/images/test.jpg
          and
          www.domain.com/folder2/images/test.jpg

          which one do you resolve to when a client comes in and asks for
          www.domain.com/images/test.jpg ?

          So, maybe the answer here is named web servers?

          Would it work if you had:

          www.folder1.domain.com/images/test.jpg
          and
          www.folder2.domain.com/images/test.jpg

          ?

            well this is for development so each folder would be considered a seperate site, like:

            /folderA/
            /folderB/

            Both would be seperate development sites which later the files would get moved to:

            folderA == www.domainA.com

            folderB == www.domainB.com

            So I'm hoping for a way to drop an .htaccess in each folder on this development server.

            I think the best way is going to be setting up subdomains though, which I'd like to avoid.

            folderA.developmentserver.com
            etc...

              Yes, the name space collision problem will not be taken care of without having some way of making everything live in a seperate space, so to speak.

                a month later

                Hi All,

                I am haveing the same problem as Smith15, in that I develop multiple sites on my local machine and then upload to the server. Problem being is keeping the links releative to both. Has anyone a solution for this???

                Thanks
                Dill

                  I've ended up just setting up subdomains on the development server.

                  There were just too many problems with some applications wanting to go all the way back to the root, or includes within includes would get screwed up.

                  It wasn't worth the headache especially when moving the sites to a production server.

                  With subdomains you don't have to do anything different and if you need to redirect to a full URL/HTTP path for some reason, just detect the domain you're on first before redirecting.

                    my setup is right on with what Sxooter suggested. i've got apache2, php, and mysql on my local machine, and have added virtualhosts to my apache httpd.conf file, just using a diff. port per project. you can have a ton of sites running this way, no issue w/ root directory problems. pretty easy to set up too. the conf file has an example. no reason couldn't be setup on a dedicated server same way also. best solution imo.

                      Originally posted by hi-liter
                      my setup is right on with what Sxooter suggested. i've got apache2, php, and mysql on my local machine, and have added virtualhosts to my apache httpd.conf file, just using a diff. port per project. you can have a ton of sites running this way, no issue w/ root directory problems. pretty easy to set up too. the conf file has an example. no reason couldn't be setup on a dedicated server same way also. best solution imo.

                      I find it easier to type:

                      whatever.domain.com

                      instead of:

                      whatever.com:8080

                      And trying to remember which port each site is on.

                        Thanks for the replys,

                        Settinmg up virtual host would be the ideal solution, but I don't have a dns server on my machine. I have tried setting VH up but no luck so not sure if it is because I don't have dns server on my machine.

                        Do you need DNS on your machine to do this?

                        Dill

                          Ok,

                          Finally got virtual host working, found out some additional info that I have not seen before. It worked for me so I thought u maybe interested.

                          Added this to my httpd.conf

                          NameVirtualHost 127.0.0.2:80

                          <VirtualHost 127.0.0.2>
                          DocumentRoot c:/phpdev/www/envirodri
                          ServerName 127.0.0.2
                          </VirtualHost>

                          added the following to host file in windows/system32/drivers/etc

                          127.0.0.2 vitualhostdamain

                          The differance from all the other instructions is useing the IP 127.0.0.2 and then increament the last number as you add more virtual domains.

                          Hope this helps any of you that r still haveing probs.

                          Dill

                            Originally posted by Hamsterpants

                            <VirtualHost 127.0.0.2>
                            DocumentRoot c:/phpdev/www/envirodri
                            ServerName 127.0.0.2
                            </VirtualHost>

                            Well, you've almost got it right there. The key here is NAMED vitual hosts. you don't need DNS on your machine, you just need a way to make sure users can resolve names. for my big box at work we have a DNS entry that is something like this: (all made up, not real numbers or names to protect the not so innocent.)

                            10.0.0.1 bigbox.comp.com techdocs.comp.com bubba.comp.com test10.comp.com .... namenumber50.comp.com

                            then, my httpd.conf file on the main server is something like:

                            Listen 10.0.0.1:80
                            NameVirtualHost 10.0.0.1
                            <VirtualHost 10.0.0.1>
                              DocumentRoot /www/bigbox
                              ServerName bigbox.comp.com
                            </VirtualHost>
                            
                            <VirtualHost 10.0.0.1>
                              DocumentRoot /www/techdocs
                              ServerName techdocs.comp.com
                            </VirtualHost>
                            

                            Then you have your DNS administrator push out the aliases for your DNS entry onto the net. note that since they're all on the same domain, that you don't have to register a domain or anything, it should be pretty easy to do if you can figure out who runs DNS and get them to do that.

                              Write a Reply...