You have to use the absolute path or, if using a relative path, use one relative to the URL, not the rewritten URL. So, if you have a script in the same folder as the page, you might have something like:
Code:
<script src="encode.js"></script>
Well, the server will be looking for that in the non-existing category folder. But if you go like:
Code:
<script src="../encode.js"></script>
it will find it in the http://localhost/norres/ folder.
Or you could use the absolute path (probably the best solution), ex (in your case with what you've told me):
Code:
<script src="http://localhost/norres/encode.js"></script>
I don't see any problem with includes* though, which should imply that all server resources accessed directly via PHP should work as if the page were not redirected. Images would have the same issues as scripts though. In fact any HTML resources (images, css files, javascript files, videos, etc.) will see the the location.href as the address in the browser's address bar and will need to have their URLs either made absolute or made relative to the address in the address bar. The absolute URL is probably the easiest, and will work no matter how the page is redirected in the future and will work even if the page is accessed without using the redirect.
A trick that might work would be to put this in the head of the HTML portion of the page, before any relative URL's:
Code:
<base href="<?php echo $_SERVER['PHP_SELF']; ?>">
Whatever method you use though, there could still be other problems for anything that's missed one way or the other. Like even with the base href method, if an external script references the location.href property in any important way that depends upon the path without accommodating the redirect, it will likely cause an error.
*It's possible, though not likely, that includes will work differently on your localhost server. However, any relative HTML URL's on them will be subject to the same limitations/issues as other relative HTML URL's that make up the page's final served HTML content.
Bookmarks