views:

35

answers:

2

Just wanted to make sure:

When I write:

require('/path/to/file/file.php');

Is the file required with respect to Apache's mod_rewrite? (which seems unreasonable, since it should be there for user URL redirection) What I mean is, that if .htaccess sends all requests to "index.php", index.php would be required instead?

And

When inside HTML markup, should paths to files e.g. images, links, css be written with respect to .htaccess mod_rewrite?

Say this is the public root: http://example.com/ The image is located in '/img/image.png' RewriteRule sends all requests with anything after the url end trailing slash to http://example.com/ Does this mean the image would not be found?

I suppose this applies to JS/CSS files as well.

A: 

Is the file required with respect to apache's mod_rewrite?

No. Never. Except if you prepend the path with a http://, in which case the HTTP wrapper will come into play and make a normal web request.

When inside HTML markup, should paths to files e.g. images, links, css be written with respect to htaccess mod_rewrite?

Absolutely. I don't understand your example but any URL you use in a HTML file will be requested by the client's browser and be subject to whatever mod_rewrite rules you have set up. The same goes for Javascript, CSS files and the like.

Pekka
Yes, your example is what I meant (I probably didn't articulate it properly). I thought so regarding the php, just wasn't very sure about the html. Thanks!
sombe
A: 

First questions: No, mod_rewrite has no influence on the path you specify in require().
Second question: Yes, it would not be found. But you can put a rewrite condition before your rewrite rule to circumvent this:

RewriteCond %{REQUEST_FILENAME} !-f

With this, the rewrite rule is only applied, if the requested file does not exist.

Felix Kling