简体   繁体   English

如何在不重写URL的情况下重定向页面?

[英]How to redirect a page without rewrite URL?

I have domain site.com and there is subdomain sub.site.com Once you open sub.site.com you have to see site.com/sub/ without URL formatting. 我有域site.com,并且有subdomain sub.site.com。打开sub.site.com后,您必须看到site.com/sub/,而没有URL格式。 How to do this? 这个怎么做?

You can create a virtual host, or vhost, to do so. 您可以创建一个虚拟主机或虚拟主机。 There you can easily define a Server Alias, that transparently redirects to your directory. 您可以在那里轻松定义服务器别名,该服务器别名将透明地重定向到您的目录。

For example, if your apache configuration looks like this: 例如,如果您的apache配置如下所示:

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

And now you add a second Virtual Host: 现在,您添加第二个虚拟主机:

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

see: http://httpd.apache.org/docs/2.0/vhosts/examples.html 请参阅: http : //httpd.apache.org/docs/2.0/vhosts/examples.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM