Question

I have a website which is purely content pages and one way to navigate around is via a link to example.com/random. The page /random picks a random page and forwards the user on to it.

What would be the best way to do this? So far I have

  • PHP's header("Location: http://example.com/123");
  • javascript redirect

Judging 'best' as one which is better for SEO unless you can think of any other massive benefits or issues

Was it helpful?

Solution

If I were you, I would use 301 redirect by HTTP Header to redirect visitor to your random page. This kind of redirect is understood by search engine robots.

Here's PHP code to perform 301 redirect:

header("Status: 301 Moved Permanently", false, 301);
header("Location: http://www.example.com/nouvelle-page.htm");
exit();

OTHER TIPS

Is the "random" page indexed? If you 301 redirect to a URL, you're going to confuse the bot, because you're telling it "this page is permanently moved to x URL" and "x" URL is random, so I think in this case I would 302 redirect.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top