AliasMatch and RegEx

大兔子大兔子 提交于 2020-06-10 04:38:10

问题


I'm working with a centralized CMS on a dev server, the CMS is in /var/www/central-cms

The site (I've many sites) is accessible by this url: http://web.localdomain.dev/site1/.

How can I access the cms simply typing this url: http://web.localdomain.dev/site1/cms?

Maybe AliasMatch is the solution? Any help with the RegExp?

Example

http://web.localdomain.dev/stackoverlow/

http://web.localdomain.dev/google/

http://web.localdomain.dev/yahoo/

etc.

If I append a /cms to the url, this URL point to /var/www/central-cms


回答1:


Unless I'm missing something, it looks like a simple Alias directive would work:

Alias /site1/cms /var/www/central-cms

If this doesn't work, you may need to provide us with more details regarding your configuration.

If you want to accomplish this for multiple sites, you can use the AliasMatch directive. You can look at the AliasMatch documentation for more information, including some good examples, but in the end you'll end up with something like this:

AliasMatch ^/[^/]*/cms(.*) /var/www/central-cms$1

This means that an access to /site1/cms/foo will go to /var/www/central-cms/foo...and so will a request for /site2/cms/foo.

The expression [^/]* matches any number of characters other than /, which is important here so that the string cms appearing elsewhere in the URL doesn't cause problems.



来源:https://stackoverflow.com/questions/9906433/aliasmatch-and-regex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!