Pages: 12Next
Current Page: 1 of 2
How to get absolute links working
Posted by: taylor223 (---.zone3.bethere.co.uk)
Date: December 12, 2009 10:36AM

hello, I'm using Wamp server offline for development and I've got an alias set up for a site im working on. All the sites files and folders are within a folder named siteroot. This folder has been setup as an alias to try and replicate the directory structure on the hosting server. Trouble is all my absolute links aren't working, the relative ones are fine.

eg
/home/folder/folder/file.php

doesn't work.

I need the siteroot folder to function as the server siteroot. Is this possible and how?

Options: ReplyQuote
Re: How to get absolute links working
Posted by: stevenmartin99 (---.b-ras2.blp.dublin.eircom.net)
Date: December 12, 2009 02:33PM

ul need to place you website in that path then...

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: How to get absolute links working
Posted by: taylor223 (---.zone3.bethere.co.uk)
Date: December 12, 2009 02:50PM

my site is in that path already.

folder siteroot is currently the alias. All web files are in here.

eg. ........siteroot/home/folder/file.php
and the absolute link should be
/home/golder/file.php

not working though

Options: ReplyQuote
Re: How to get absolute links working
Posted by: stevenmartin99 (---.b-ras2.blp.dublin.eircom.net)
Date: December 12, 2009 03:21PM

hosts online do not use the HOME folder as part of the path so maybe thats why ur links are not working

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: How to get absolute links working
Posted by: taylor223 (---.zone3.bethere.co.uk)
Date: December 12, 2009 04:01PM

There seems to be some confusion here, the 'home' folder is one I have created. Everything within siteroot (local) has been generated by myself.

The alias folder of 'siteroot', which contains all these files/folders I have generated, is meant to replicate the host root.

ie.
siteroot/ should equal hostroot/
siteroot/home/ should equal hostroot/home/

the folder named 'home' within 'siteroot' (local) should have an absolute path of /home/

I am only using WAMP server for offline development and NOT online. All I need to do is get absolute paths working on my alias folder.

Options: ReplyQuote
Re: How to get absolute links working
Posted by: stevenmartin99 (---.b-ras2.blp.dublin.eircom.net)
Date: December 12, 2009 04:20PM

do u mean tho that in ur html /php files, you have absolute paths ?


im just expaining that a host online would not be abe to access anything less then the www/ pubic folder..


so if you have a site that ur moving to test on ur pc.. you do not want the home folder in your path. the aliad should take you to the dirst folder with html pages




anyway post up ur alias file and ill look at it

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: How to get absolute links working
Posted by: taylor223 (---.zone3.bethere.co.uk)
Date: December 12, 2009 04:48PM

yea, there are some absolute paths within my php files.

eg
require('/supportingfiles/pagelayout/header.inc.php');

the 'supportingfiles' folder is in the hostroot folder so has no other structure above it (wwwpublic folder/supportingfiles/...etc)

this also applies to the home folder (wwwpublicfolder/home/...etc


heres the config:


Alias /siteroot/ "d:/projects/5. websites/2. in progress/village/siteroot/"

<Directory "d:/projects/5. websites/2. in progress/village/siteroot/">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
Allow from all
</Directory>

Options: ReplyQuote
Re: How to get absolute links working
Posted by: c2dan (---.15-1.cable.virginmedia.com)
Date: December 12, 2009 04:56PM

If you have setup Aliases these will not be available to PHP for use in file paths.

PHP does not request for files through Apache.

Options: ReplyQuote
Re: How to get absolute links working
Posted by: stevenmartin99 (---.b-ras2.blp.dublin.eircom.net)
Date: December 12, 2009 04:56PM

as i sed, hosts HOME folders dont contain html fies . HOME is above ROOT but BELOW PUBLIC HTML
/WWW


your alias shoud be pointing to d:/projects/5. websites/2. in progress/village/siteroot/home





also "5. websites" ? and "2. in progress"

are these folder names?

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: How to get absolute links working
Posted by: taylor223 (---.zone3.bethere.co.uk)
Date: December 12, 2009 06:18PM

Ignore the fact its called HOME, it's just a folder name and has nothing to do with the host. I created the folder HOME within the host directory. It could easily be called folder1 or anything else.

This is the directory structure within the wwwpublic folder:

folder1
folder2
folder3


These are the first folders within the www public folder, I cannnot place them any higher in the directory.
If I have a php file in 'folder1/subfolder1/' that i want accessable by any php document then the absolute path would be '/folder1/subfolder1/file.php' even if the two php documents were in the same folder.

All I've done locally is have the same directory structure and instead of the folders being in 'www public folder' they are in the folder named 'siteroot'. The alias points to this 'siteroot' folder.

Options: ReplyQuote
Re: How to get absolute links working
Posted by: taylor223 (---.zone3.bethere.co.uk)
Date: December 12, 2009 06:18PM

and yea "5. websites" ? and "2. in progress" are lcoal folder names

Options: ReplyQuote
Re: How to get absolute links working
Posted by: taylor223 (---.cluster-j.blackspider.com)
Date: December 12, 2009 08:31PM

this is the full absolute path to my web files/folders (works online)
/home/account/public_html/domain/

So the absolute path to
www.domain.com/home/index.php
would be
/home/account/public_html/domain/home/index.php


Is it possible have the absolute paths work locally using Wamp server?


Did a $_SERVER['DOCUMENT_ROOT'] to compare online against local and I think cdan may be right in saying the absolute path doesn't work using wampserver. Thats going to screw up testing and development with my current site somewhat.

Options: ReplyQuote
Re: How to get absolute links working
Posted by: stevenmartin99 (---.b-ras2.blp.dublin.eircom.net)
Date: December 12, 2009 09:37PM

but these are not absolute , absolute need to start with http://

anyway i understand what you mean now and yes its possible useing apaches mod_rewrite only

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: How to get absolute links working
Posted by: taylor223 (---.cluster-j.blackspider.com)
Date: December 13, 2009 07:49AM

just to clear things up for anyone that reads this.

[www.domain.com] - is a URL

/folder/file.php - a / at the beginning is an absolute path based on the web servers root (will be much longer than that, just an example)

../folder/file.php - ../ is a relative path

folder/file.php - starting with a folder name is a relative path



Setting up a virtual host may be a simpler option. Did some searching and it seems to be the solution to my issue and pretty straight forward, will try it out later on.


how involved is the mod_rewrite?

Options: ReplyQuote
Re: How to get absolute links working
Posted by: stevenmartin99 (---.b-ras2.blp.dublin.eircom.net)
Date: December 13, 2009 08:03AM

i dont think you understand how wamp is layed out...


the abosulte paths using /folder will be read as [localhost] or c:/wamp/www/folder

unlike a host online where ur base path can be before the public folder , wamp is not like this


root/home/public/site/file.php public can only see from public >



of course absolute paths can be used on wamp.. but they start from www/




yes you can use vhosts to start the user in a specfic folder

but as i told you this is the same as deleting all ur folders below the first point of access u want the user to have..



having /home in the www means is accessaible... where as having a vhost to push them into the site folder wil mean they can no longer access anything below.



of course if you plan only 1 site then u would change the document root and not the vhost

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: How to get absolute links working
Posted by: taylor223 (---.zone3.bethere.co.uk)
Date: December 13, 2009 04:55PM

I already do understand that, it's why I'm on here trying to figure out how to have Wamp match the online hosts way of seeing root.

I'm trying to use Wamp offline only for development, which works until absolute links (non-http) are used.


All I want to do is set d:/folder/etc.../siteroot/ as the starting point for my absolute paths

So in my PHP document the absolute path is
/home/account/public_html/domain/foldername/index.php

which matchs the online hosts absolute path to my directory structure of
/home/account/public_html/domain/

(works online just fine)

and in wamp the 'siteroot' folder will be seen as the document root so
D:/folder/etc/etc/siteroot/home/account/public_html/domain/foldername/index.php

is effectively
/home/account/public_html/domain/foldername/index.php
when viewing the php doument


at the moment the document root is D:/folder/etc/etc/siteroot/.....

which doesn't work

Options: ReplyQuote
Re: How to get absolute links working
Posted by: stevenmartin99 (---.b-ras2.blp.dublin.eircom.net)
Date: December 13, 2009 04:58PM

doc root shud be

D:/folder/etc/etc/siteroot/home/account/public_html


or set up vhost to do the same

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: How to get absolute links working
Posted by: taylor223 (---.zone3.bethere.co.uk)
Date: December 13, 2009 06:32PM

I don't know how many more times I can explain the same thing.

I appreciate you still trying to help when others would have just stopped replying but theres some kind of misunderstanding here

The document root IS D:/folder/etc/etc/siteroot/home/account/public_html

Thats the problem, I need the doc root to look like this /home/account/public_html
so it replicates the host.

Going to read the instructions for a vhost and go that way. Seems like the best solution.


PS- Liked you in Planes, Trains, and Automobiles but Bowfinger was a let down.

Options: ReplyQuote
Re: How to get absolute links working
Posted by: c2dan (---.15-1.cable.virginmedia.com)
Date: December 13, 2009 08:07PM

Rather than have your file paths hard coded as
include "/home/account/publlic_html/somefile.php";

Substitute '/home/account/publlic_html/' with the $_SERVER['DOCUMENT_ROOT'] var , eg

include $_SERVER['DOCUMENT_ROOT'] ."/somefile.php";

Setting up vhosts or aliases will not help you. PHP does not request for files through Apache, therefore PHP will not know that home/account/publlic_html/ is an alias to D:/folder/etc/etc/siteroot/home/account/public_html. Aliases/vhosts only work through HTTP requests.

The problem is you have hard coded your file paths. Doing this will make your code less portable.

Options: ReplyQuote
Re: How to get absolute links working
Posted by: taylor223 (---.cluster-j.blackspider.com)
Date: December 13, 2009 08:52PM

won't that just use the document root of the file you're viewing rather than pointing to an exact place in the directory structure?

Options: ReplyQuote
Pages: 12Next
Current Page: 1 of 2


Sorry, only registered users may post in this forum.