AliasMatch和RegEx [英] AliasMatch and RegEx

查看:117
本文介绍了AliasMatch和RegEx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发服务器上使用集中式CMS,CMS在/var/www/central-cms

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

该站点(我有很多站点)可以通过以下URL访问:http://web.localdomain.dev/site1/.

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

我如何仅输入以下URL即可访问cms:?

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

也许AliasMatch是解决方案?对RegExp有帮助吗?

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

示例

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

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

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

如果我在URL后面附加/cms,则此URL指向/var/www/central-cms

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

推荐答案

除非我丢失了某些内容,否则它看起来像一个简单的Alias指令即可工作:

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.

如果要在多个站点上完成此操作,则可以使用AliasMatch指令.您可以查看 AliasMatch文档以获得更多信息,包括一些信息.很好的例子,但最终您会得到类似以下的内容:

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

这意味着对/site1/cms/foo的访问将转到/var/www/central-cms/foo ...,因此对/site2/cms/foo的请求也将访问.

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.

表达式[^/]*匹配除/之外的任意数量的字符,这在这里很重要,这样,出现在URL中其他位置的字符串cms不会引起问题.

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.

这篇关于AliasMatch和RegEx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆