Strelok2014Strelok
Strelok2014Strelok

Reputation: 123

How can I implement an alias in .htaccess in Apache configuration?

How can I implement an alias in .htaccess in Apache configuration? Thank U)

Alias /static "/var/www/core/static" 
<Location "/static"> 
    SetHandler None #
</Location>

Upvotes: 1

Views: 3301

Answers (1)

Jon Lin
Jon Lin

Reputation: 143946

You can't use Alias in an htaccess file. You can do something similar using mod_rewrite but you can not alias to a folder outside of the document root. That means, in your example, if /var/www/core/static isn't in your document root, then you can't link to it. The htaccess file is a "per directory" context, and has no way of knowing anything that is outside of the document root.

The mod_rewrite way works something like this:

RewriteEngine On
RewriteRule ^static/(.*)$ /core/static [L]

Assuming that /core/static is inside your document root. If not, there's nothing you can do with an htaccess file.

Upvotes: 3

Related Questions