简体   繁体   中英

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. 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:

<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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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