不带重定向的 Apache 虚拟目录
我想要完成的是从与 url 路径不同的目录中提取内容。例如:
- URL:example.com/
- 路径:/www/product/
目前,根 url 从上面的路径中提取内容。我想要做的是这样的:
- URL:example.com/
- 路径:/www/products/root/
因此基本 URL“example.com”应该不是从 /www/products/ 而是从 /www/products 提取数据/根/。
我认为这在 IIS 中称为虚拟目录。 Apache中有类似的东西吗?
编辑以澄清:
我有大量现有内容,但我还不想重组。然而,根站点正在完全重建,并且会变得更大。我想要的是每个微型网站都有自己的目录,这样对 example.com/ 的请求应该从 /www/product/root/ 中提取内容,而对 example.com/microsite/ 的请求仍然应该从 /www/product/ 中提取内容微型网站/。
希望这更有意义。 :)
What I'm trying to accomplish is pulling content from a directory that is not the same as the url path. For example:
- URL: example.com/
- path: /www/production/
Currently, the root url pulls content from the path above. What I want to do is something like this:
- URL: example.com/
- path: /www/production/root/
So the base URL "example.com" should pull data not from /www/production/ but from /www/production/root/.
I think this is called a Virtual Directory in IIS. Is there something like this in Apache?
Edit for clarification:
I have a ton of existing content that I do not want to have to restructure yet. However, the root site is being completely rebuilt and is going to be quite a bit bigger. What I want is each microsite to have it's own directory, such that requests for example.com/ should pull content from /www/production/root/ while requests for example.com/microsite/ should still pull content from /www/production/microsite/.
Hopefully that makes more sense. :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它不完全清楚你的问题是什么。如果您只想获取相对于服务器上某个位置的所有 URL,那么您可以使用
DocumentRoot
指令:如果您只想让某些 URL 转到新位置,那么您可以使用 mod_alias 模块中的
Alias
或AliasMatch
指令。它们可以将 URL 上的前缀或 url 正则表达式映射到其他服务器位置。如果这还不够,您可以使用 mod_rewrite,它允许任意链的 url 重写,但维护起来可能会很麻烦,所以如果可以的话,最好避免使用该模块。http://httpd.apache.org/docs/2.0/mod/mod_alias。 html
Its not exactly clear what your problem is. If you just want all URLs to be taken relative to some location on the server, then you can use the
DocumentRoot
directive:If you want to only have certain urls go to the new place, then you can either use the
Alias
orAliasMatch
directives from the mod_alias module. These can map either prefixes on a URL, or url Regexes to other server locations. If even this isn't sufficient, you can use mod_rewrite which allows for arbitrary chains of url rewriting, but can get very hairy to maintain, so you're better off avoiding that module if you can.http://httpd.apache.org/docs/2.0/mod/mod_alias.html
如果我正确理解您的问题,那么您的 VirtualHost 配置中的以下内容可以满足您的要求:
If I understand your question correctly, then the following, in your VirtualHost config, does what you're asking for: