AliasMatch and RegEx

2020-06-21 01:56发布

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条回答
我只想做你的唯一
2楼-- · 2020-06-21 02:37

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.

查看更多
登录 后发表回答