Blog Email GitHub

18 Nov 2010


Alias /project_name/images/ /home/project/project_name/htdocs/images/
Alias /project_name/css/ /home/project/project_name/htdocs/css/
Alias /project_name/js/ /home/project/project_name/htdocs/js/
AliasMatch ^/project_name/(?!app/)(.*) /home/project/project_name/htdocs/$1
WSGIScriptAlias /project_name/app /home/project/project_name/


  1. http://domain/project_name/app
  2. http://domain/proejct_name/app/


  1. 修改AliasMatch的正则表达式,修改成”/proect_name/((?!app).* app(?!/).+)”
  2. 将WSGIScriptAlias 放到AliasMatch前面

方案1是可行的。方案2我原以为是可用性的,原因(from [][]):

Aliases and Redirects occuring in different contexts are processed like other directives according to standard merging rules. But when multiple Aliases or Redirects occur in the same context (for example, in the same <VirtualHost> section) they are processed in a particular order.

First, all Redirects are processed before Aliases are processed, and therefore a request that matches a Redirect or RedirectMatch will never have Aliases applied. Second, the Aliases and Redirects are processed in the order they appear in the configuration files, with the first match taking precedence.

但是经过验证,不可行,我就怀疑 Alias和WSGIScriptAlias的优先级了,google了下,的确有人说Alias要比WSGIScriptAlias的优先级要高。在官方文档只找到这句话(from

When listing the directives, list those for more specific URLs first. In practice this shouldn’t actually be required as the Alias directive should take precedence over WSGIScriptAlias, but good practice all the same. \ Do note though that if using Apache 1.3, the Alias directive will only take precedence over WSGIScriptAlias if the mod_wsgi module is loaded prior to the mod_alias module. To ensure this, the LoadModule/AddModule directives are used. For more details see section ‘Alias Directives And Apache 1.3’ in Installation Issues.