Avatar of oaktrees
oaktrees

asked on 

Does This Code Qualify as OK for 301 Redirect --> Positive Google SEO?

Need to get our website to resolve to our secure pages.

Seems like the best way, in terms of SEO, is via a 301 redirect.

Would this code be a 301 redirect?

if($_SERVER['HTTP_X_FORWARDED_PROTO']=="http"){
header('Location:https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
exit;
}

Open in new window


Or, will this be looked at as, not only NOT 301, but somehow seemingly the WRONG way to achieve our goal and result in a SEO penalty?

Many thanks!

OT
Web DevelopmentSearch Engine Optimization (SEO)PHP

Avatar of undefined
Last Comment
Julian Hansen

8/22/2022 - Mon