Forum Moderators: phranque

Message Too Old, No Replies

Used to paginate using htaccess now I want to redirect indexed pages

dynamic url redirect

         

stupidzbu

7:47 am on Jan 4, 2011 (gmt 0)

10+ Year Member



This has been driving me a little crazy.

RewriteRule ^foo/([0-9]+)_(.+)/([0-9]+)/$ /FOO.php?p=$3&variable=$1 [NC,L]


This code creates different pages for foo/variable/page_number .. but I now list everything on foo/variable/1/ and want to redirect all the pages already indexed back to foo/variable/1/

So I thought I would write a condition as follows

RewriteCond %{QUERY_STRING} ^foo/([0-9]+)_(.+)/([0-9]+)?$ [NC]
RewriteRule ^$ /foo/$1_$2/1/ [NC,R=301,L]
RewriteRule ^foo/([0-9]+)_(.+)/(1)/$ /FOO.php? p=$3&variable=$1 [NC,L]


where I would first convert the original query to foo/variable/1/ and then rewrite that URL

but it failed.

any ideas?

jdMorgan

7:34 pm on Jan 5, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's a lot easier to get good answers if you provide details:
  • What URL(s) are you testing with?
  • What filepath(s) do you want to rewrite each of those URLs to?
  • How -specifically- did it fail? What did you see in your browser? What is in your server error log? How did these results differ from your expectations?

    Jim
  • stupidzbu

    8:31 pm on Jan 5, 2011 (gmt 0)

    10+ Year Member



    www.url.com/(0-9)+_text_string/1/ is the desired URL

    I had created multiple pages that were indexed www.url.com/1_name/2/ .../n/

    I want the /2/ ... /n/ to redirect to /1/

    When I tried the above code, I got the data from
    www.url.com/(0-9)+_text_string/1/ (no 404 error)

    but the URL stayed the same (no redirect) for all page numbers. So I know something is working, I'm just not sure what isn't working, why /n/ doesn't redirect to /1/