douxun1934 2014-03-16 20:56
浏览 66
已采纳

重定向初始页面有效,但下一页显示浏览器中的旧URL

I have the following .htaccess code:

RewriteEngine On
RewriteBase /


RewriteCond %{THE_REQUEST} \s/+Category\.php\?pageNum_RS_Search=([^\s&]+)&totalRows_RS_Search=([^\s&]+)&Category=([^\s&]+) [NC]
RewriteRule ^ /Compare/page/%1/%1/%1? [R=301,L]

RewriteCond %{THE_REQUEST} \s/+Category\.php\?Category=([^\s&]+) [NC]
RewriteRule ^ /Compare/%1? [R=301,L]

RewriteCond %{THE_REQUEST} \s/+product\.php\?id=([^\s&]+) [NC]
RewriteRule ^ %1? [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)?$ product.php?id=$1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^Compare/([^/]+)/?$ Category.php?Category=$1 [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^Compare/page/([^/]+)/([^/]+)/([^/]+)/?$ Category.php?pageNum_RS_Search=$1&totalRows_RS_Search=$2&Category=$3 [L,QSA] 

The redirect for the Category.php?Category=.. works fine, but when I want to go to the next page of this category so keeping ^Compare/Category name to the next page with this code gives me ^Compare/page/1/1/1 and as a result the next page is looking for category 1, it should be looking for category category name. Is there a way to show: ^Compare/page/1/8/Category name? The eight is just a number of the total rows the 1 is obviously the page number and the Category is the Category name. The next page is created with dreamweavers navigation bar using php. Any help welcome

  • 写回答

1条回答 默认 最新

  • dongwei3336 2014-03-16 21:33
    关注

    This is due to your faulty very first rule where your are using %1 again & again instead of %2 and %3.

    It should be this:

    RewriteCond %{THE_REQUEST} \s/+Category\.php\?pageNum_RS_Search=([^&]+)&totalRows_RS_Search=([^&]+)&Category=([^\s&]+) [NC]
    RewriteRule ^ /Compare/page/%1/%2/%3? [R=301,L]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)