Does Apache Alias support relative paths?

7

I'm trying to alias a file using a relative path from the document root, like this:

Alias /js/jquery-1.9.1.min.js lib/jquery-1.9.1/jquery-1.9.1.min.js

It does not work, but I can't find anything in the documentation about relative paths.

Does it support relative paths?

face

Posted 2014-08-15T08:30:45.517

Reputation: 93

Answers

4

You can use a relative directory-path (or file-path) as the target of the Alias directive. However, it is relative to the ServerRoot, not the DocumentRoot.

One of the main uses of the Alias directive is to be able to access files outside of the current DocumentRoot, so it wouldn't necessarily be logical to have this resolve relative to the DocumentRoot.

If you wanted to "alias" file(s) relative to the DocumentRoot, then you can use mod_rewrite. For example, in a server or virtualhost context:

RewriteEngine On
RewriteRule ^/js/((jquery-1\.9\.1)\.min\.js)$ /lib/$1/$2 [L]

Reference:

MrWhite

Posted 2014-08-15T08:30:45.517

Reputation: 2 414