dongmi1663 2013-08-27 04:09
浏览 53
已采纳

301重定向不适用于查询字符串

I've .htaccess file which contains some 301 redirects. See the .htaccess code below. The third 301 redirect works fine. But the first and second redirects are producing 404 Page not found result. I've searched over SO and google and found some solutions. But none of them are working.

Following is my .htaccess file:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Redirect 301 /page.php?page=8  http://www.mydomain.com/about-us/

Redirect 301 /page.php?page=5  http://www.mydomain.com/contact-us/

Redirect 301 /testimonial.php http://www.mydomain.com/testimonials/

Please suggest.

  • 写回答

2条回答 默认 最新

  • dsndm82062 2013-08-29 14:46
    关注

    I've tried many was found here in SO and google.com; Nothing worked. Finally, I used a different approach. I've created page.php file and there I used following code:

    $page = $_GET['page'];
    switch ($page) {
    case 6:
    $link = 'http://webindream.com/about-us/';
    break;
    
    case 7:
    $link = 'http://webindream.com/contact-us';
    break;
    
    default: 
    $link = 'http://webindream.com/';
    
    
    }
    
    header("Location: $link", true, 301);
    

    Hope this will help someone to get rid of .htaccess and redirect smoothly.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 运筹学中在线排序的时间在线排序的在线LPT算法
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧