{"id":2473,"date":"2016-05-17T11:40:28","date_gmt":"2016-05-17T18:40:28","guid":{"rendered":"http:\/\/www.wellgolly.com\/?p=2473"},"modified":"2016-05-17T11:40:28","modified_gmt":"2016-05-17T18:40:28","slug":"redirecting-missing-links","status":"publish","type":"post","link":"https:\/\/www.wellgolly.com\/?p=2473","title":{"rendered":"Redirecting missing links"},"content":{"rendered":"<p>I just updated a site so that it works better on phones and tablets. While updating I also cleaned up a lot of old code. In the process of cleaning up many of the old pages are no longer valid. Rather than redirecting to a generic page, I can redirect certain links to specific missing link pages. This is what I did for old manuals pages that I moved.<\/p>\n<p><pre><code class=\"preserve-code-formatting\">\n&lt;?php\n$oldurl = $_SERVER[&#039;REQUEST_URI&#039;];\n\/\/ Redirect requests for manuals\nswitch ($oldurl) {\n&nbsp;&nbsp;case &#039;\/products\/mobile\/manual_1.php&#039;;\n&nbsp;&nbsp;case &#039;\/products\/mobile\/manual_2.php&#039;;\n&nbsp;&nbsp;case &#039;\/products\/mobile\/manual_3.php&#039;;\n&nbsp;&nbsp;case &#039;\/products\/mobile\/manual_4.php&#039;;\n&nbsp;&nbsp;etc.\n\n&nbsp;&nbsp;&nbsp;&nbsp;header(&quot;Location: https:\/\/www.wellgolly.com\/products\/manuals_mobile.php&quot;,TRUE,301);\n&nbsp;&nbsp;&nbsp;&nbsp;break;\n}\n?&gt;\n&lt;div&nbsp;&nbsp;class=&quot;centered&quot;&gt;\n&lt;h1&gt;Error 404&lt;br \/&gt;Document not found&lt;\/h1&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;img class=&#039;pure-img-responsive centered&#039; src=&#039;\/images\/sad.png&#039; alt=&#039;Sad&#039; \/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;p&gt;We\u2019re sorry, but the page you requested could not be found.&lt;br \/&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;Please use the menus at the top or bottom of this page to find what you are looking for.&lt;\/p&gt;\n\n&lt;\/div&gt;<\/code><\/pre><\/p>\n<p>By parsing the $oldurl, you can redirect missing files from sections of your site to a missing page that can help your visitors find what they are looking for rather than just a generic page.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I just updated a site so that it works better on phones and tablets. While updating I also cleaned up a lot of old code. In the process of cleaning up many of the old pages are no longer valid. Rather than redirecting to a generic page, I can redirect certain links to specific missing &hellip; <a href=\"https:\/\/www.wellgolly.com\/?p=2473\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Redirecting missing links<\/span><\/a><\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28],"tags":[],"class_list":["post-2473","post","type-post","status-publish","format-standard","hentry","category-html-and-css"],"_links":{"self":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/posts\/2473","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2473"}],"version-history":[{"count":0,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=\/wp\/v2\/posts\/2473\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wellgolly.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}