SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: Transferring PR

  1. #1
    SitePoint Wizard GoldFire's Avatar
    Join Date
    Oct 2002
    Location
    Oklahoma City, OK
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Transferring PR

    Okay, here is my problem. I am redoing my whole site, but trying to keep all the same URLs so I don't lose my PR. I know you can use a 301 to transfer the PR, but for one of my pages right now it is like http://example.com/profile/1, but I want to make it like http://example.com/profile/1/Game-Name to get the keywords in the URL as well. Is there a way to transfer the PR from all pages like the first one to all pages like the second without manually putting in each redirect?

  2. #2
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Plano
    Posts
    643
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well you already use mod-rewrite to forward pages w/the first syntax to another page. just instead of fowarding to that page, foward to a redirect script, which sets 301 codes in the headers to forward to the second syntax, which mod-rewrites to the page you want.

    i'm not sure if that makes any sense, lemme try some code.

    so you'd want your .htaccess...
    Code:
    RewriteRule ^profile/([0-9]*)$ redirectscript.php?id=$1 [NC,L]
    RewriteRule ^profile/([0-9]*)/([a-zA-Z-]+)$ realscript.php?id=$1 [NC,L]
    then you'd have your redirectscript.php...
    PHP Code:
    /**code here to get the desired keyword **/
    header("HTTP/1.1 301 Moved Permanently");
    header("Location: http://example.com/profile/$id/$keyword");
    exit(); 
    i believe that should work...someone correct me if i'm wrong

  3. #3
    SitePoint Wizard GoldFire's Avatar
    Join Date
    Oct 2002
    Location
    Oklahoma City, OK
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you, that seems to work. Does anyone know if this will actually transfer the PR?

    Also, I am not sure what this part is for:

    Code:
    RewriteRule ^profile/([0-9]*)/([a-zA-Z-]+)$ realscript.php?id=$1 [NC,L]
    I didn't include that and it redirected like you described.

  4. #4
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Plano
    Posts
    643
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i included that because the page redirect.php 301's the page to the new format, which is /profile/1/Game-Name. Once this page is accessed, it needs to be mod-rewritten again to go to the actual page that shows what you want.

    if u use redirect.php to redirect DIRECTLY to the script that displays all your information, then PR will be passed to /profile.php?id=1, not /profile/1/Game-Name.

    i may be missing something though, and if it works for you, and the URL looks correct in the end, then i wouldn't worry about it.

  5. #5
    SitePoint Wizard GoldFire's Avatar
    Join Date
    Oct 2002
    Location
    Oklahoma City, OK
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't use mod rewrite to change profile.php to profile. The actual name of the file is profile and I use ForceType so I don't need the second mod rewrite. Thanks, seems to work great


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
  •