【问题标题】:How to redirect a page without rewrite URL?如何在不重写 URL 的情况下重定向页面?
【发布时间】:2012-04-10 17:44:57
【问题描述】:

我有域 site.com 并且有子域 sub.site.com 打开 sub.site.com 后,您必须看到没有 URL 格式的 site.com/sub/。 如何做到这一点?

【问题讨论】:

  • 您认为您使用的网络服务器可能相关?
  • 您应该定义一种语言 ;) 您要重定向的语言。您不能使用每种语言进行重定向。
  • Anton,请在下一个问题中发布您尝试过的内容;社区随时为您提供帮助,但您也必须展示您的尝试;您很快就会看到人们会问:您尝试过什么?甚至链接都可以完成这项工作

标签: apache url mod-rewrite redirect rewrite


【解决方案1】:

您可以创建一个虚拟主机或虚拟主机来执行此操作。在那里,您可以轻松定义服务器别名,透明地重定向到您的目录。

例如,如果您的 apache 配置如下所示:

<VirtualHost 13.37.13.37>
DocumentRoot /www/where/ever/your/webroot/is
ServerName www.example.net
</VirtualHost> 

现在您添加第二个虚拟主机:

<VirtualHost 13.37.13.37>
DocumentRoot /www/where/the/other/site/is
ServerName example.net
ServerAlias othersite.example.net
</VirtualHost> 

见:http://httpd.apache.org/docs/2.0/vhosts/examples.html

【讨论】:

  • 有没有办法不使用root权限?我没有。
  • 没有。然后你必须使用 .htaccess 和 mod_rewrite。但是你的网址会失去它的“漂亮”......
猜你喜欢
  • 2013-10-12
  • 1970-01-01
  • 2017-08-06
  • 2011-09-28
  • 2011-04-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多