Welcome to the JaguarPC Community
JaguarPC
Sales: (888) 338-5261
Support: (888)-551-3050
Results 1 to 3 of 3

This is a discussion on 301 redirect with variables in old page URL in the VPS & Dedicated forum
i am just about to launch a new site but want to make sure all the old links get individually redirected to the new pages ...

  1. #1
    JPC Member
    Join Date
    Jan 2009
    Posts
    2

    Angry 301 redirect with variables in old page URL

    i am just about to launch a new site but want to make sure all the old links get individually redirected to the new pages via the 301 method. i have done this no problem in the past with simple pages e.g. pagename.asp, however my issue is all the old pages are made up with string variables e.g.

    OLD PAGES:
    page.jsp?id=lcruises/departures2009
    page.jsp?type=4&id=contact
    page.jsp?type=1&id=groups&page=donnakime s2009

    this is what i have tried for the first old link, to no avail. please can someone help me for all 3 types! many thanks in advance!

    RewriteRule ^page.jsp?id=cruise_info/princess$ /ship-detail-12.php? [R=301]

  2. #2
    Community Leader jason's Avatar
    Join Date
    Sep 2001
    Location
    Rochester, NY
    Posts
    6,003
    Although represented as a single string in the browser, URLs actually get split into many different pieces when they are sent to the server. In this case, the QUERY_STRING is split from the URI path and sent as a separate header, so mod_rewrite doesn't see the query string in the RewriteRule directive.

    One fix would be to do something like this for each of your redirects:

    RewriteCond %{QUERY_STRING} ^id=cruise_info/princess$
    RewriteRule ^page.jsp$ /ship-detail-12 [R=301,L]

    Perhaps an easier way would be to continue using the page.jsp file to receive the requests and using it to redirect as appropriate. My J2EE skills are a little lacking, but it shouldn't be increadibly difficult to do. In PHP you'd do something like this:

    PHP Code:
    <?php
    header
    ('HTTP/1.0 301 Moved Permanently');

    if(
    $_SERVER['QUERY_STRING'] == 'id=cruise_info/princess') {
        
    //location headers should contain a full URL
        
    header('Location: http://www.yoursite.com/ship-detail-12.php');
    }
    ?>
    --Jason
    Jason Pitoniak
    Interbrite Communications
    www.interbrite.com www.kodiakskorner.com

  3. #3
    JPC Member
    Join Date
    Jan 2009
    Posts
    2
    thanks Jason. i had to go the .htaccess route..that worked. one thing i did added was a ?, on the 2nd line, at the end, after to stop the old variable string being placed on the end of the new one redirection.

    RewriteCond %{QUERY_STRING} ^id=cruise_info/princess$
    RewriteRule ^page.jsp$ /ship-detail-12? [R=301,L]

    many thnks!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •