Can I use meta refresh instead of 301 redirect?

Can I use meta refresh instead of 301 redirect? - If a page has internal and external outgoing links to redirecting URLs, it’s returning 3xx (301, 302, etc.) HTTP status codes standing for redirection. This issue means that the page does not exist on a permanent or temporary basis. It appears on most of the popular web browsers, usually caused by a misconfigured website. However, there are some steps you can take to ensure the issue isn’t on your side. You can find more details about redirecting URLs by reading the Google Search Central overview. In this article, we’ll go over how you can fix the Can I use meta refresh instead of 301 redirect? error on your web browser. Problem :


I have submitted my site with ugly URLs to Google, and now they are appearing as mysite.com/show.php?id=42.



Now, I know that I can 301-redirect it to mysite.com/article/42. However, my site uses the URL form like stack exchange, so like this mysite.com/article/42/title-of-my-article which is in fact index.php?what=content&id=42&title=title-of-my-article.



Therefore, I cannot use only .htaccess for this, right?



So will it work if I do this?




  • Keep show.php as the redirect node

  • if user comes to show.php?id=42 , get the article of title with id=42, and echo "<meta http-equiv='refresh' content='0; url=http://mysite.com/article/42/$title'>



It will work for the visitors, but will it help Google to understand and change the URL to the new one?


Solution :

In your show.php it looks like you have the title you need for the URL. So instead of echoing the meta tag, use PHP to do a 301 redirect:



header("HTTP/1.1 301 Moved Permanently"); 
header("Location: http://mysite.com/article/42/$title");

We hope that this article has helped you resolve the google, redirects, 301-redirect error in your web browsers. Enjoy browsing the internet uninterrupted!

Comments

Popular posts from this blog

Redirected urls show in serp, with the original permalink but with the title and meta of the target page

How can I redirect everything but the index as 410?

How do I redirect traffic only if being accessed from a specific port?