0

I want to change my link from usercp.php?do=our_pics&p=$i to usercp/our_pics/1.

I have this .htaccess code

RewriteEngine On
RewriteRule usercp/(.*)/(.*) usercp.php?do=$1&p=$2

The problem is when I using the pagination to change the page to another, it doing redirect to main page or page 1, and that because there are problem in mod_rewrite code .

"Edit 1"

After enable RewriteLog and RewriteLogLevel 2, the following is the content of rewrite.log file When the problem occurs.

127.0.0.1 - - [06/Jan/2013:20:37:26 +0200] [localhost/sid#6828d0][rid#ec2180/initial] (2) [perdir C:/Program Files/wamp/www/ebdaa_v3/] rewrite 'usercp/our_pics/3' -> 'usercp.php?do=our_pics/3'

127.0.0.1 - - [06/Jan/2013:20:37:26 +0200] [localhost/sid#6828d0][rid#ec2180/initial] (2) [perdir C:/Program Files/wamp/www/ebdaa_v3/] strip document_root prefix: C:/Program Files/wamp/www/ebdaa_v3/usercp.php -> /ebdaa_v3/usercp.php

127.0.0.1 - - [06/Jan/2013:20:37:26 +0200] [localhost/sid#6828d0][rid#ec2180/initial] (1) [perdir C:/Program Files/wamp/www/ebdaa_v3/] internal redirect with /ebdaa_v3/usercp.php [INTERNAL REDIRECT]

127.0.0.1 - - [06/Jan/2013:20:37:26 +0200] [localhost/sid#6828d0][rid#724160/initial/redir#1] (1) [perdir C:/Program Files/wamp/www/ebdaa_v3/] pass through C:/Program Files/wamp/www/ebdaa_v3/usercp.php

127.0.0.1 - - [06/Jan/2013:20:37:26 +0200] [localhost/sid#6828d0][rid#ec6190/initial] (2) [perdir C:/Program Files/wamp/www/ebdaa_v3/] rewrite 'usercp/mainpage' -> 'usercp.php?do=mainpage'

127.0.0.1 - - [06/Jan/2013:20:37:26 +0200] [localhost/sid#6828d0][rid#ec6190/initial] (2) [perdir C:/Program Files/wamp/www/ebdaa_v3/] strip document_root prefix: C:/Program Files/wamp/www/ebdaa_v3/usercp.php -> /ebdaa_v3/usercp.php

127.0.0.1 - - [06/Jan/2013:20:37:26 +0200] [localhost/sid#6828d0][rid#ec6190/initial] (1) [perdir C:/Program Files/wamp/www/ebdaa_v3/] internal redirect with /ebdaa_v3/usercp.php [INTERNAL REDIRECT]

127.0.0.1 - - [06/Jan/2013:20:37:26 +0200] [localhost/sid#6828d0][rid#727158/initial/redir#1] (1) [perdir C:/Program Files/wamp/www/ebdaa_v3/] pass through C:/Program Files/wamp/www/ebdaa_v3/usercp.php
Lion King
  • 111
  • 5

2 Answers2

0

If I understand you well, you need to rewrite the link from usercp.php?do=our_pics&p=$i to read usercp/our_pics/1. If so, you can try the following rewrite rules:

RewriteEngine on
RewriteCond %{QUERY_STRING} ^do=(.*)&p=([0-9]*)$
RewriteRule usercp\.php$ /usercp/%1/%2? [R=302,L]

It seems that I did not understand your question well. The example in your question is not consistent with your rewrite rule. If you want to do the rewrite in the opposite direction, you can try this block:

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/usercp/(.*)/([0-9]*)$
RewriteRule .* /usercp.php?do=%1&p=%2 [R=302,L]

This should convert the URL from usercp.php?do=our_pics&p=$i to usercp/our_pics/1.

Khaled
  • 35,688
  • 8
  • 69
  • 98
0

Turn on your RewriteLog to find out what's breaking.

RewriteLog /path/to/log
RewriteLogLevel 2

This will give you details on each and every step that mod_rewrite is taking, so that you can see where the logic is going wrong.

Andrew M.
  • 10,982
  • 2
  • 34
  • 29