1

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?

JMC
  • 496
  • 6
  • 21

1 Answers1

2

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

Andrew M.
  • 10,982
  • 2
  • 34
  • 29
  • 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 02:11