Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

doc_root outside IIS root?

Posted on 2005-03-06
4
Medium Priority
?
642 Views
Last Modified: 2013-12-13
Dear all,

I have a website hosted on Apache; I develop, however, using IIS IIS 5.1 on Windows XP.

I want a generic template such that I can use both of (for example):
 * include("/home/mysite/public_html/includes/public.php");
 * <link rel="stylesheet" type="text/css" href="/stylesheets/public.css" />
(where /home/mysite/public_html is the root to my website on the live server).

This is fine on the live box, but I cannot replicate it locally - let the physical path to the local root directory be c:\mywebsite\home\mysite\public_html - if I set the IIS root directory to be c:\mywebsite, the PHP include works fine but the stylesheet link is wrong; if I set the IIS root directory to be c:\mywebsite\home\mysite\public_html the stylesheet link works fine but the PHP include breaks.

I thought about setting the doc_root in php.ini to c:\mywebsite and the IIS root directory to c:\mywebsite\home\mysite\public_html, but then IIS returns a 404 error whenever it tries to interpret a PHP page.

Any suggestions? - I don't particularly want to install Apache or start setting include paths every time I use PHP...

Many thanks in advance,

Paul
0
Comment
Question by:pdb086
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
matt_mcswain earned 1000 total points
ID: 13474191
Just use relative paths for everything. Unless there's files you're making available for download or something outside the document root.  Are you aware of the $_SERVER['DOCUMENT_ROOT'] variable?
0
 
LVL 2

Author Comment

by:pdb086
ID: 13474842
That's what I'm doing at the moment; I want to do it like this so it can just be dropped into any page, but also so that if the page is moved to a different directory at any point it can cope with it; I don't really want to start trawling through code in future...
0
 
LVL 11

Expert Comment

by:matt_mcswain
ID: 13479412
Ok
Literally use:

include $_SERVER['DOCUMENT_ROOT'].'/includes/public.php';

Where the doc_root is either
c:\mywebsite\home\mysite\public_html
or
/home/mysite/public_html

and for web links literally use

"/stylesheets/public.css"
"/images/picture.png"

or even better for links

<? echo 'http://'.$_SERVER['HTTP_HOST'].'/stylesheets/public.css';?>


0
 
LVL 2

Author Comment

by:pdb086
ID: 13481674
Matt,

Many thanks - I hadn't realised those variables were available to PHP - should have looked through phpinfo() more carefully, I guess - just goes to show that sometimes you do just need to state the obvious... :D

Just for the record, I develop ASP.NET/MS SQL on IIS; I'm perfectly competent at that, honest...

Thanks again,

Paul
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question