Forum Moderators: phranque
I'm trying to setup a .htaccess file to handle all url's with a / at the beginning. I don't want to be using ../ requests within my sites. I want all requests to start from the root folder. For examples "/images/bg.jpg" or whatever.
Problem is my sites are set up within sub-folders, so any requests start outside of the websites folder.
My server root folder is,
192.168.0.80/Web/
Within there is a folder called
192.168.0.80/Web/mysite
So if I have a link such as <a href="/about-us"> it looks for "192.168.0.80/about-us", which of course won't work cause it needs to go to "192.168.0.80/Web/mysite/about-us"
I having no luck getting anything to work and any help would be greatly appreaciated.
Thanks!
You must put the correct URL in the link on your pages.
If you have full control over the server, put the correct path to DocumentRoot in your server config file, and this will avoid the whole problem. It seems that the DocumentRoot path is currently missing the "/mysite" path-part.
Jim
The DocumentRoot needs to stay as is, but any folder created with the root needs to become the root for that site.
So say my server has the following folders,
/Web
/site-1
/site-2
/site-3
If I have a page within /Web/site-1 and the link is "/about-us" that needs to go to /Web/site-1/about-us, not outside of the "site-1" directory as it does presently.
I haven't had any luck finding any specific answers yet, and I've Googled it to death.
hostname/filename ......... filepath below root
www.site1.com/filename --> /site1/filename
www.site2.com/filename --> /site2/filename
Here, part of the hostname "www.site1.com" is used in the rewritten URL as the subdirectory. This can be done directly, as shown, or associatively, using a lookup techniique if the hostname does not directly match the directory name.
If the hostnames are all the same, then once a relatively-linked URL resolves to your server root, there is no longer any information to figure out which subdirectory to point it "back" to.
I suspect there is some degree of mis-communication here, and that I am not understanding how your server is set up, and the URLs that you use to access these "sites" that you describe.
Jim
[edited by: jdMorgan at 9:36 pm (utc) on July 28, 2008]
I'm hoping to set it up so it mimics a live environment and I can use URL's like the ones I described above with a beginning /. I'm not sure how else to explain it.
As it stands with no info available in the requested URL to identify which 'site' the request came from and should be 'corrected' for, there is no solution that does not involve hard-coding the subdirectory path -- thus requiring you to change it whenever you want to work on another site.
The basic problem is that the server is not set up to support the environment you need. Anything short of fixing that problem is just a band-aid/work-around/kludge.
Jim