tags:

views:

82

answers:

1

Hello,

I have a couple of sites that are currently under development and I've put them under a specific subfolder for clients/co-workers to view - "http://dev.staffanestberg.com/site-name/". I've run into some problems getting the sites working with .htaccess. I can reach the index page by typing in the url for a site folder but neither img/style/js/etc linking or page rewriting works. Looking for a solution to this, Apache's "RewriteBase" seems to be the most likely one, however I can't get it to work. Tried RewriteBase http://dev.staffanestberg.com/site-name/ RewriteBase /site-name What would be the correct method?

Thanks in advance, -Staffan

A: 

mod_rewrite’s RewriteBase directive does only apply to rewrites using RewriteRule. And that does only apply for requests that are sent to the server.

But if the requested URIs are already wrong, RewriteBase doesn’t do any help. What you could try instead is the HTML element BASE that set’s the base URI for the current document.

Gumbo
Ah, I see. I did try the HTML base href tag but it didn't help. Perhaps I gave it an incorrect url? Tried http://dev.staffanestberg.com/site-name/. Note that the links are all given an "/" before their respective names (for example, "/logo.png").
Staffan Estberg
@Staffan Estberg: Only the relative parts are resolved from that base URI; absolute parts are adopted as they stand. In your case the absolute URI path `/logo.png` is adopted as it stands and not resolved from `/site-name/` (in fact, resolving `/logo.png` from `/site-name/` yields `/logo.png`). To get `/site-name/logo.png` you will either need to use a relative path like `logo.png` or `./logo.png` or the absolute path `/site-name/logo.png`.
Gumbo
Ok! Thanks for the info. I replaced all occurances of "/x" with "./x". Problem solved!
Staffan Estberg
@Staffan Estberg: Note that a base URI effects *all* relative URIs and not just relative URI paths.
Gumbo