4

My question is on Stack Overflow 301 dynamic redirection.

I asked a question few days before & generated URL for that was:

http://stackoverflow.com/questions/34632473/not-able-to-execute-a-jar-file-using-php-exec-function-while-it-running-well-th

I edited my question title, and the new URL generated is:

http://stackoverflow.com/questions/34632473/not-able-to-execute-a-jar-file-using-php-exec-function-though-it-running-well-th

And now the old URL is also redirecting to the new one (301). I want to know how did Stack Overflow implemented it or what are ways in which it could be done.

I know Stack Overflow team is very open with their project architectures, technologies & server config so I hope they could share how it is done.

0

1 Answer 1

5

The title does not matter because it bases everything off the id from /questions/34632473/, try this out:

Not able to execute a jar file using php exec, though it works in the terminal

It is the URL:

https://stackoverflow.com/questions/34632473/blah-blah-blah 

It will do a lookup based on the id of the URL then redirect the question to match the SEO'd title string for the URL if it does not currently match.

In code it might look something like this:

if ($question['slug_url']!=urlencode($current_slug)) {
    // 301 Redirect for search engines
    $this->_redirect('/question/34632473/'.$question['slug_url'], 301);
    return;
}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .