Difference between PHP and .htaccess redirection

Is there any difference between php header redirection and htaccess redirection using SEO site?

+3
source share
2 answers

Probably not - it depends on how you redirect.

In PHP:

header("Location: http://www.example.com/"); /* Redirect browser, emits 302 */

If you want to fix 301, use:

header("Location: http://www.example.com/", true, 301);

See the PHP documentation for more details .

If you do this in your own .htaccess:

Redirect 302 /PATH_TO_REDIRECT http://www.example.com/

then it will also emit 302.

Again, to emit 301, it's simple:

Redirect 301 /PATH_TO_REDIRECT http://www.example.com/

, SEO, , . - 301, - (, ), 302 ( ).

+4

, , .

0

Source: https://habr.com/ru/post/1720779/


All Articles