PHP Redirection

Discussion in 'PHP' started by supersubi, Aug 14, 2007.

  1. #1
    Hi,

    I have a website with more than 1000 pages. Now I want to rename the file names to make it more SEO friendly. My friend suggested me to rename it to improve the search engine ranking. For example,

    currently I have:

    page234.php

    I want to change it to:

    php-example.php

    Is the PHP redirection method will help? what is the best method to achieve this?

    please help.
     
    supersubi, Aug 14, 2007 IP
  2. mikeloring

    mikeloring Guest

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    ....i'm confused. are you talking about renaming files or redirecting your pages?

    for redirecting, just use:
    header (Location: URL);

    otherwise, i don't think theres a php function to rename files on a web server, but i'd try PHP.NET if anything.
     
    mikeloring, Aug 14, 2007 IP
  3. Wildhoney

    Wildhoney Active Member

    Messages:
    192
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #3
    Wildhoney, Aug 14, 2007 IP
  4. supersubi

    supersubi Banned

    Messages:
    557
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Sorry for the confusion. I am going to rename the files and remove the old files. So, I need to redirect all the old files to new files.
     
    supersubi, Aug 14, 2007 IP
  5. void

    void Peon

    Messages:
    119
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Along the lines of what mikeloring suggested - strip the content out of the old files and just replace it with
    <?php
    header("HTTP/1.1 301 Moved Permanently");
    header ("Location: http://www.yoursite.com/yournewpage.php");
    ?>
    PHP:
    This redirects users and tells spiders to reindex using the new address.

    Edit: SE backlinks and PR will eventually migrate to the new address too.
     
    void, Aug 14, 2007 IP
  6. jakomo

    jakomo Well-Known Member

    Messages:
    4,262
    Likes Received:
    82
    Best Answers:
    0
    Trophy Points:
    138
    #6
    Hello,

    There are two ways:

    1- header() In your PHP as said void
    2- htaccess
    IE:
    RewriteRule ^page234.php?$ /php-example.php.php [QSA,L]

    Best,
    jakomo
     
    jakomo, Aug 14, 2007 IP
  7. supersubi

    supersubi Banned

    Messages:
    557
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    okay. thanks. I have some files which are static html. How can I redirect those files ? Also, how it reacts with SE's?

    for example I have:

    page234.html

    I want to redirect it to:

    php-example.php

    thank you:)
     
    supersubi, Aug 28, 2007 IP