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?
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.
- Permissions issue with virtual directory to UNC path
- How can I prevent people from looking at a listing of files in parent directory if I haven’t uploaded index.html?
- IIS 6 – how to create virtual directory like /my/custom/path
- Parse PHP in HTML files – files download instead of parse
- Apache RewriteRule to treat images, css and js files as normal
Leave a comment
- SCP transfer only modified files
- How can I automate clearing and resetting a Linux user’s home directory to a default?
- Cron expression that runs every 5 minutes from 1:30 am – 6:00 am [duplicate]
- Understanding redundant power supplies
- Is there a way for administrators to disable users from installing Firefox extensions?