niammuddin

redirect 404 ke search wordpress

Mar 23rd, 2014
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. <?php
  2. function ganti_setiap_karakter($minta) {
  3.         $minta = htmlspecialchars($minta);
  4.                 $minta = str_replace('/search/', '', $minta);
  5.         $minta = str_replace('/', '', $minta);
  6.         $minta_a = explode(' ',$minta);
  7.         $minta_baru = array();
  8.         foreach ($minta_a as $baru) {
  9.             $minta_baru[] = ucwords(trim($baru));
  10.         }
  11.         $minta = implode(' ', $minta_baru);
  12.         return $minta;
  13.     }
  14. ?>
  15. <?php
  16. if($_SERVER['REQUEST_URI']){
  17. $gantikode = array (' ','++','+++','-');
  18. $urlredirect = get_settings('home') . '/article/' . strtolower(str_replace($gantikode, '-' ,ganti_setiap_karakter($_SERVER['REQUEST_URI']))) . '/';
  19. header("HTTP/1.1 301 Moved Permanently");
  20. header( "Location: $urlredirect" ) ;
  21. die();
  22. }
  23. ?>
Add Comment
Please, Sign In to add comment