301 Redirection in PHP

by 7 replies
8
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
#search engine optimization #301 #php #redirection
  • Banned
  • write below code to top of the page :
  • 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
  • PHP redirect using the 301 "moved permanently" redirection.
    • [1] reply
    • 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
  • 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.
  • 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!)

Next Topics on Trending Feed