Home >php教程 >php手册 >一个二级域名跳转的代码

一个二级域名跳转的代码

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-21 09:05:532192browse

二级域名

  • 利用上面的代码可以用二级域名的形式来访问http://www.域名1/文件夹/中对应的文件夹内的网页,比如二级域名为:http://520.域名1.com,经过上面的代码就可以直接访问http://www.域名1.com/文件夹/520/
    1. <font face="新宋体"><span style="COLOR: #0000bb"></span><span style="COLOR: #0000bb"> </span></font>
    2. <font face="新宋体"><span style="COLOR: #0000bb">$x</span><span style="COLOR: #0000bb"> </span><span style="COLOR: #007700">=</span><span style="COLOR: #0000bb"> </span><span style="COLOR: #0000bb">str_replace</span><span style="COLOR: #007700">(</span><span style="COLOR: #dd0000">'.域名1'</span><span style="COLOR: #007700">,</span><span style="COLOR: #dd0000">''</span><span style="COLOR: #007700">,</span><span style="COLOR: #0000bb">$_SERVER</span><span style="COLOR: #007700">[</span><span style="COLOR: #dd0000">'HTTP_HOST'</span><span style="COLOR: #007700">]</span><span style="COLOR: #007700">)</span><span style="COLOR: #007700">;</span><span style="COLOR: #0000bb"> </span></font>
    3. <font face="新宋体"><span style="COLOR: #007700">if</span><span style="COLOR: #0000bb"> </span><span style="COLOR: #007700">(</span><span style="COLOR: #0000bb">$x</span><span style="COLOR: #0000bb"> </span><span style="COLOR: #0000bb">!=</span><span style="COLOR: #0000bb"> </span><span style="COLOR: #dd0000">"www"</span><span style="COLOR: #0000bb"> </span><span style="COLOR: #007700">&&</span><span style="COLOR: #0000bb"> </span><span style="COLOR: #0000bb">$x</span><span style="COLOR: #0000bb"> </span><span style="COLOR: #0000bb">!=</span><span style="COLOR: #0000bb"> </span><span style="COLOR: #dd0000">""</span><span style="COLOR: #007700">)</span><span style="COLOR: #0000bb"> </span><span style="COLOR: #007700">{</span><span style="COLOR: #0000bb"> </span></font>
    4. <span style="COLOR: #0000bb"><font face="新宋体">Header</font></span><font face="新宋体"><span style="COLOR: #007700">(</span><span style="COLOR: #dd0000">"Location:http://www.域名1.com/文件夹/"</span><span style="COLOR: #007700">.</span><span style="COLOR: #0000bb">$x</span><span style="COLOR: #007700">.</span><span style="COLOR: #dd0000">"/"</span><span style="COLOR: #007700">)</span><span style="COLOR: #007700">;</span><span style="COLOR: #0000bb"> </span></font>
    5. <font face="新宋体"><span style="COLOR: #007700">}</span><span style="COLOR: #007700">else</span><span style="COLOR: #007700">{</span><span style="COLOR: #0000bb"> </span></font>
    6. <span style="COLOR: #0000bb"><font face="新宋体">Header</font></span><font face="新宋体"><span style="COLOR: #007700">(</span><span style="COLOR: #dd0000">"Location:http://www.域名2.com"</span><span style="COLOR: #007700">)</span><span style="COLOR: #007700">;</span><span style="COLOR: #0000bb"> </span></font>
    7. <font face="新宋体"><span style="COLOR: #007700">}</span><span style="COLOR: #0000bb"> </span></font>
    8. <span style="COLOR: #0000bb"><font face="新宋体">?></font></span>


  • Statement:
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Previous article:相册程序Next article:WORD排版