Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I tried to create a development server by copying a website from one host to a second different host, but the servers seem to handle virtual paths differently.

On the main server this works:

<link href="/styles/styles.css" rel="stylesheet" type="text/css">

On the dev server the same path would need to be written as (without the first slash):

<link href="styles/styles.css" rel="stylesheet" type="text/css">

How can I make the dev server work with the main servers files without rewritting the paths? Is this something I can do from .htaccess with mod rewrite?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

First, some background on how paths work. Absolute paths are based on the server root. Relative paths are based on the URL (not the file path) of the current page. However, this behavior is NOT handled by the server--its handled by the client, and this behavior is universal (Yes, even IE6... I know, surprise!). The only thing that would cause these two paths to NOT be the same would be if they're not relative to the root of the web site.

For example, if we're trying to access the URL you mentioned above (/styles/styles.css), here's how they would behave on the following two examples:

"Main Server" web site hosted at http://mainwebsite/index.html

styles/styles.css  => http://mainwebsite/styles/styles.css
/styles/styles.css => http://mainwebsite/styles/styles.css

"Dev Server" web site hosted at http://devsite/some_sub_dir/index.html

styles/styles.css  => http://devsite/some_sub_dir/styles/styles.css
/styles/styles.css => http://devsite/styles/styles.css

If you clarify your answer (these servers are clearly not hosting the same data in the same way), I could provide a more accurate description. However, if I had to guess, I'd say you're probably running into the issue I described.

Good luck!

Andrew

share|improve this answer
    
What you've described makes sense. I'll try it out on Monday and post back if I need more help. Thanks –  JMC Nov 20 '10 at 2:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.