301 Redirection in PHP

7 replies
  • SEO
  • |
Hello friends

I have a website in PHP, I have created some new pages in my site and want to redirect old page to new page..

For example..

www.abc.com/abc.php should be redirect to /abcd.php

Guys can you please help me that how can I redirect old page to new page.


Thanks
#301 #php #redirection
  • Profile picture of the author yukon
    Banned
    {{ DiscussionBoard.errors[9213619].message }}
  • Profile picture of the author sathish5566
    write below code to top of the page :
    header("location:www.abc.com/abcd.php");
    {{ DiscussionBoard.errors[9213667].message }}
  • Profile picture of the author patadeperro
    What you will need is to use regular expression and write them in you.htaccess, here are a couple of regular expresion builders that may be useful to you:

    RegExr: Learn, Build, & Test RegEx

    Rubular: a Ruby regular expression editor and tester

    The regular expressions will tell the htaccess the redirections you want to create, but there needs to be certain pattern or structure to your ancient urls, otherwise it is a never ending process
    {{ DiscussionBoard.errors[9214331].message }}
  • Profile picture of the author ChristinaCa
    PHP redirect using the 301 "moved permanently" redirection.
    {{ DiscussionBoard.errors[9215534].message }}
    • Profile picture of the author paulgl
      Chap asked about php coding, not htaccess.

      It's a very simple 2 line code. A simple google search will find it,
      I am 100% sure.

      header("Location.... will make it a 302, which is no big deal actually.

      I'm not supplying the code because people need to do research,
      experiment, learn, etc. You gotta know the whys, hows, and wheres.

      Paul
      Signature

      If you were disappointed in your results today, lower your standards tomorrow.

      {{ DiscussionBoard.errors[9216214].message }}
  • Profile picture of the author yukon
    Banned
    The link for the Google search I posted has a php 301 redirect example (code) on the 3rd ranked site:
    • hxxp://www.phatz.com/301redirect.php

    I don't mind helping people but stuff like this usually only takes a simple Google search.
    {{ DiscussionBoard.errors[9216643].message }}
  • Profile picture of the author patco
    I have only 1 question... I am really curious how can you create a good website in PHP and can't do a simple redirection (the HEADER function [if I can call it a function] is maybe the start when talking about PHP!)
    Signature

    A blog that will show you How to Lose Weight with a cool Quick Weight Loss guide...
    Also enjoy some of my favorite Funny pictures and photos that will make you smile :)

    {{ DiscussionBoard.errors[9216723].message }}

Trending Topics