Search code examples
.htaccesshttp-redirectseohttp-status-code-301

htaccess or php 301 redirect url


I do not know a lot htaccess and redirect url (301) with php as;

header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: http://www.exampledomain.com" );

Is there any difference or advantage between the two for google?Can I must use htaccess for redirect url?


Solution

  • You have to use both these headers to redirect something permanently. Both headers are needed. I echo this same header for my old blog url. And I get all the referrals, visitors, inlinks from google to the new domain.

    It does not matter how you echo the headers. It matters those headers exist.

    I know PHP well so I have used a PHP file that echos only these headers

    HTTP/1.1 301 Moved Permanently
    Location: http://shiplu.mokadd.im/
    

    If you use 302 redirect Google will remember your current url and associate all your links to that old url.