第一种:
百度为例:
如果你搜索CSDN URL 就是http://www.baidu.com/s?wd=csdn
而不是http://www.baidu.com/s/?wd=csdn 或者 http://www.baidu.com/s/index.php?wd=csdn
请问百度这种方式是怎么实现的,s是什么东西第二种:
去哪为例:
你搜索机票 URL 就是http://flight.qunar.com/site/oneway_list.htm?searchDepartureAirport=%E4%B8%8A%E6%B5%B7&searchArrivalAirport=%E5%B9%BF%E5%B7%9E&searchDepartureTime=2010-05-23&searchArrivalTime=2010-05-26&nextNDays=0&startSearch=true&from=qunarindex而不是http://flight.qunar.com/site/oneway_list.php?searchDepartureAirport=%E4%B8%8A%E6%B5%B7&searchArrivalAirport=%E5%B9%BF%E5%B7%9E&searchDepartureTime=2010-05-23&searchArrivalTime=2010-05-26&nextNDays=0&startSearch=true&from=qunarindex请问这种方式是怎么实现的大家讨论下。 可能方法不是只有一种知道麻烦分享下,谢谢。。

解决方案 »

  1.   

    http://www.baidu.com/index.php
    http://www.baidu.com/index.htm
    http://www.baidu.com/index.html
    http://www.baidu.com/都能访问到百度但这并不能肯定,一定访问到了它服务器上的名为"index.php[执行后结果],index.htm,index.html"文件总之,你Google下url rewrite知识
      

  2.   

    还真像楼上,我访问http://www.baidu.com/wocaonima.pi就出来个404错误。index.rst也是404错误,大家应该看明白了
      

  3.   

    百度的可没那么简单了。
    第二种的 网站则是以ajax实现的。当然也可以用urlrewrite
      

  4.   

    你用过PHP的MVC框架吗?
    如果没有,就去了解一个.上面有人说URL rewrite,这个可以实现,并且一般都是如此,在PHP的MVC框架中多数都实现了这个功能比如,你访问http://www.XXX.com/xxx/yyy,看到了内容,但这个网站并没有这个/XXX/yyy目录,就是因为使用了URL rewrite,在Apache中,实现的方式是打开目录的AllowOverride 为All,如下:<Directory "E:/website/SellCars/public">
        AllowOverride All
        Options All
    </Directory>然后在这个目录下加.htaccess文件,里面加上入口点重写语句,如下:
    RewriteEngine onRewriteCond %{SCRIPT_FILENAME} !-f
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1就可以将提交的请求定向到E:/website/SellCars/public/index.php文件上,
    你就可以在index.php中进行路由选择,显示特定的页面,下面对你说的http://www.baidu.com/s?wd=csdn的模拟:
    在Apache中加入以下代码,创建虚拟主机:
    NameVirtualHost *:80<VirtualHost *:80>
    ServerName localhost
    DocumentRoot "E:/website/localhost"

    <Directory "E:/website/localhost">
        AllowOverride All
        Options All
    </Directory>

    </VirtualHost>
    (此后服务器重启!!!)
    然后在E:/website/localhost下创建.htaccess文件,内容按上面的填,在这个目录下建立index.php,在页面中加以下代码,你就可以看到GET请求中的数据:
    <?php
    var_dump($_GET);测试:输入http://localhost/s?wb=csdn显示:
    array(1) { ["wb"]=>  string(4) "csdn" } 注意,localhost中并无s目录/文件,但请求是成功的
      

  5.   

    至于第二种嘛,呵呵,也是服务器做到的,你可以在Apache中增加与PHP关联的扩展,比如将*.html映射到PHP上.比如你看看你现在的浏览器地址,不是有个
    ...1e61606c-0f10-4c6c-be93-22ae2798b69f.html?seed=13936656...吗?CSDN也有这个东西,不过它用的是ASP.NET