Php - A simple redirect maintaining the URL?
How can I make a redirect while forcing the url to not change?
I.E.: I access http://sub.domain.com 开发者_运维百科, it will open index.php where it will redirect to somewhere else while maintaining the url: http://sub.domain.com
Thanks.
You can use a RewriteRule. This functionality is the main point of the mod_rewrite module.
EDIT: I hesitate to post an example without testing, but it should be something like:
RewriteRule ^/$ /index.php
^/$
just means a single / character at both the beginning and end of string (i.e. that's the only character). This corresponds with the last / in http://sub.domain.com/.
EDIT 2: This doesn't apply, since John has clarified "somewhere else" is not the same host.
You could hide the redirection via iFrames. Or possible a file_get_contents() could be used to get a new page. Not sure why you'd want to do this tho.
精彩评论