前提条件:
1. 已经开启了apache url rewrite的模块
2. 已经有.htaccess文件问题:
以前所有的目录文件都放在php的文件夹下,以至于所有页面的访问方式都是xxx.com/php/..。
现在要把它调整过来,我把php文件夹下的所有文件都放到网站根目录下了。
但是以前的发给客户的链接xxx.com/php/product_info.php不能用了。
我想通过url rewrite将xxx.com/php/product_info.php重定向到xxx.com/product_info.php。
product_info.php只是其中一个页面,以前所有访问xxx.com/php/..的页面都要重定向到xxx.com/..
求指教啊。

解决方案 »

  1.   

    url地址重写 RewriteEngine On RewriteCond %{QUERY_STRING} ^(.*)$
     RewriteRule ^/([^\/]+)/php/([^\/]+)  /$1%1 [L,NC]
      

  2.   

    貌似不行诶,我试了一下。还是404 page not found
      

  3.   


    <?php 
    switch ($_SERVER["HTTP_HOST"]) 

    case "www.baidu.com": 
    header("location:wwwbaidu/index.php"); 
    break; 
    case "baidu.com": 
    header("location:baidu/index.html"); 
    break; 

    ?>
      

  4.   


    header方式明显不行啊。得用htaccess文件进行301重定向。不过还是谢谢了。
      

  5.   


    url地址重写过后,服务器需要重启一下,如果还是不行,那就不清楚了
      

  6.   

    编辑 .htaccess
    加上规则。
    重定向www.baidu.com到baidu.com 
    RewriteEngine On 
    RewriteCond %{HTTP_HOST} !^baidu.com$ [NC] 
    RewriteRule ^(.*)$ http://baidu.com/$1 [L,R=301]