| home | forums |
resources |
search |
news | join | members: 6381 |
|
Hiveminds | Mon, 2008-07-14 20:42 tags: Here is a simple script in PHP that will mimic the Apache mod_rewrite using common error pages. Call it for example 404.php and configure it to be your custom 404 error page. All you have to is to customize the last part of the page and to fill the $redirection array with the old/new paths pairs (taken from your mod_rewrite settings). If you're not using Windows, replace eregi with ereg and eregi_replace with ereg_replace (because only Windows is case insensitive with file names). We have updated the script with isset as you suggested. We have also added a new header() statement to set explicitly the status code. With no status code, an internal redirection is done and the final displayed page will still have the status code 404 which can cause problems for people with Internet Explorer and its friendly error pages. With the explicit status code set, 404 is superceded and people will get to the right page regardless of their browser settings. Notice we've used the not very known status code 307 which is a variant of the 3xx status codes. It instructs the server to retry the request with the new URL which is equivalent to the behavior of 302 with GET. But it will also force the browser to resend any POSTed data to the new URL if the method is POST (which is not possible with other status codes). You can also use the status code 301 instead of 307 if your pages do not contain forms.
<?phpThis article brought to you by the
Hiveminds Magazine - Staff. Contact us if you want to post an article or announcement anonymously |
Web Developers London Hotels
Silverlight Laptop Reviews
eRuby Just Dial International Calls
Drupal Excel Training Courses
Adobe Flex PHP excel courses in london
Silverlight Data Recovery
Adobe Flex
|
NewsletterGet updates on Hiveminds services, articles and downloads by signing up for the newsletter. |
Editor's choiceSome of the better articles, stories and tutorials found at Hiveminds. |
Find moreFind more of Hiveminds articles, stories, tutorials and user comments by searching. |
Picked linksHand picked websites and articles from around the web that provide quality reading. |