Relative Paths, etc. on an Apache server

Posted by Matt H. on Stack Overflow See other posts from Stack Overflow or by Matt H.
Published on 2011-01-03T21:02:58Z Indexed on 2011/01/03 21:53 UTC
Read the original article Hit count: 272

Filed under:
|
|
|

I'm really stuck here.

I have 2 issues at once:

First, my site is stored (both on local development and on live server), in a subdirectory.. as I'm working on multiple sites. i.e.

/Sites/www.mysite.com/(site files here)

When I'm referring to files in my web pages, I want to refer to, say, my /images directory without hard-coding every occurrence as /www.mysite.com/images/myfile.jpg

Is there a way to simply redefine how the leading "/" gets interpreted by the server?

Question two, concerning PHP mod_rewrite

I have this set of rewrite rules. The objective is to turn www.mysite.com/faq into www.mysite.com/index.php?page="faq"

RewriteEngine On
RewriteCond %{REQUEST_URI} !mysite.com
RewriteRule (.*) mysite.com/$1
RewriteRule ^([a-zA-Z0-9_-]+)$ /mysite.com/index.php?site=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ /mysite.com/index.php?site=$1

I don't have a problem when a url gets passed in the 2nd-to-last format (as the example above). However, if the trailing "/" is added: www.mysite.com/faq/, my external script references break: (such as src=js/script.js)...

© Stack Overflow or respective owner

Related posts about php

Related posts about apache