重写URL无法在localhost中运行

I tried hiding my .php extensions with .htaccess at first.. It did work fine after including this in the file

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php

and also including this in my function.php

//==== Strip .php extension from requested URI  
function strip_php_extension()  
{  
  $uri = $_SERVER['REQUEST_URI'];  
  $ext = substr(strrchr($uri, '.'), 1);  
  if ($ext == 'php')  
  {  
    $url = substr($uri, 0, strrpos($uri, '.'));  
    redirect($url);  
  } 
}  

//==== Redirect. Try PHP header redirect, then Java, then http redirect
function redirect($url)  
{  
  if (!headers_sent())  
  {  
    /* If headers not yet sent => do php redirect */  
    header('Location: '.$url);  
    exit;  
  }  
  else  
  {
    /* If headers already sent => do java redirect */  
    echo '<script type="text/javascript">';  
    echo 'window.location.href="'.$url.'";';  
    echo '</script>';  

    /* If java is disabled => do html redirect */  
    echo '<noscript>';  
    echo '<meta http-equiv="refresh" content="0; url='.$url.'" />';  
    echo '</noscript>';  
    exit;  
  }  
} 

Thing is the url for dynamic pages did not change.. I still have page.php?p=5 and blog.php?post=5 not changing to page?p=5 and blog?post=5..

I do want to change the above dynamic pages url to something nice like www.yourdomian.com/5 for page.php and www.yourdomain.com/blog/5 for the blog, but this is not reading it from my ReWrite rule in htacces

RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ page.php?p=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ page.php?p=$1

Kindly point me in the right direction as to what am doing wrong. and how to fix it.

You can use these rules in /MyApp/.htaccess:

Options -MultiViews
RewriteEngine On
RewriteBase /MyApp/

RewriteCond %{THE_REQUEST} /page\.php\?([a-z])=([^&\s]+)
RewriteRule ^ %1/%2? [R=302,NE,L]

RewriteCond %{THE_REQUEST}  /blog\.php\?post=([^&\s]+) [NC]
RewriteRule ^ blog/%1? [R=302,NE,L]

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]

RewriteRule ^blog/([^/]+)/?$ blog.php?post=$1 [L,NC,QSA]

RewriteRule ^([a-z])/([^/.]+)/?$ page.php?$1=$2 [L,QSA]