1

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

Ria
  • 516
  • 6
  • 24

1 Answers1

0

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]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • I have added another rule for the news page which works fine on the local server, however when I upload it to the main server it can't find the page. What am I doing wrong? RewriteCond %{THE_REQUEST} \s/+news\.php\?news_id=([^\s&]+) [NC] RewriteRule ^ /news/%1? [R=301,L]RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^news/([^/]+)/?$ news.php?news_id=$1 [L,QSA]. Will start a new question – Ria Mar 17 '14 at 13:17
  • http://stackoverflow.com/questions/22455539/htaccess-works-on-local-server-not-on-main-server this is the link – Ria Mar 17 '14 at 13:24
  • Sure let me check other question. – anubhava Mar 17 '14 at 14:05