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 r语言神经网络自变量重要性分析
  • ¥15 基于双目测规则物体尺寸
  • ¥15 wegame打不开英雄联盟
  • ¥15 公司的电脑,win10系统自带远程协助,访问家里个人电脑,提示出现内部错误,各种常规的设置都已经尝试,感觉公司对此功能进行了限制(我们是集团公司)
  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢