htaccess在php中重写

I had to remove .php extension and I got success with using

 RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
 RewriteRule ^ %1 [R,L]
 RewriteCond %{SCRIPT_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^([^\.]+)$ $1.php [NC,L]

Now I had to create pretty url as ssfront/category/id/MQ../t/f/name/Accounting From ssfront/category.php?id=1&t=f&name=Accounting And I got success using

 RewriteRule category/id/(.*)/t/(.*)/name/(.*) category.php?id=$1&t=$2&name=$3 [L,B]

But get problem when I echo $_GET['name'] , It gives Accounting.php

ie

echo $_GET['name']

out put : Accounting.php instead of Accounting

But i actually need Accounting as output

I tried solution

     $name_ =  substr($_GET['name'], 0,strrpos($_GET['name'],'.')); 

But I dont think this is solution should be apply so Is there any master and easy solution ?

Try

RewriteRule category/id/(.*)/t/(.*)/name/(.*) category.php?id=$1&t=$2&name=$3 [L,QSA]

Update:

This .htaccess work fine in my server:

RewriteEngine On

#RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
#RewriteRule ^ %1 [R,L]

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

RewriteRule ^category/id/([^/]+)/t/([^/]+)/name/(.*)(?:.php)$ category.php?id=$1&t=$2&name=$3 [L,QSA]

In category.php (with url test.local/category/id/1/t/2/name/3:

var_dump($_GET['name']);
// Output: string(1) "3" 

Keep it this way:

 RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
 RewriteRule ^ %1 [R,L]

 RewriteCond %{SCRIPT_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^([^\.]+)/?$ $1.php [NC,L]

 RewriteRule ^category/id/([^/]+)/t/([^/]+)/name/(.*)$ category.php?id=$1&t=$2&name=$3 [L,QSA]

You can use basename function for example:

$name_ =  basename($_GET['name']);