This is a client-side problem related to your use of relative URLs. Since you are effectively rewriting the URL from /console/console.html
to /Console
, any relative URL (to images, CSS, JS, etc.) are now going to be relative to the document root and not the /console
subdirectory.
You need to either "fix" your relative URLs and make them root-relative (ie. starting with a slash, as in /console/images/1.jpg
) or make them absolute.
Alternatively, you can include a base
element in the head
section of your HTML document. This references the absolute URL that all relative URLs are relative to. In other words, since you are expecting these relative URLs to be relative to the /console/console.html
document then add the following to the head
section:
<base href="http://example.com/console/console.html">
Now, a relative URL such as images/1.jpg
referenced in a document at URL /Console
will request http://example.com/console/images/1.jpg
, not http://example.com/images/1.jpg
.
However, there are caveats with using the base
element. Notably, if you have in-page relative links using fragment identifiers, eg href="#some-id"
. This is also now relative to your base
element so the in-page link may now be broken. The only way round this is to fully qualify the link.
Reference:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
However, Alias
is not the correct directive to use when mapping to a single file, since Alias
is prefix matching, so /Console/foo
would map to /console/console.html/foo
as well. You could perhaps use AliasMatch
instead:
AliasMatch ^/Console$ /console/console.html
This will map only /Console
.
Or, you could use mod_rewrite instead and issue an internal rewrite. (As opposed to an external redirect that would otherwise change the URL and cause the client to issue a second request.) For example:
RewriteEngine On
RewriteRule ^/?Console$ /console/console.html [L]