使用htaccess文件重写动态URL

i want to display the this url

http://localhost/project/sites/sample/cat.php?typ=Politics

to like this

http://localhost/project/sites/sample/Politics.html

and my htaccess code is

RewriteEngine on
RewriteRule (.*)\.html$ cat.php?typ=$1

it's working when i was gave the url manually on browser, but the url was not loaded dynamically. i want to show the second url dynamical if i click the first url. thank you to help

Try this Rule:

RewriteEngine on
RewriteRule (.*).html$ cat.php?typ=$1

Change RewriteRule to Redirect:

RewriteEngine on
Redirect (.*)\.html$ cat.php?typ=$1

*By the way, "typ" is written as "type"

If you want to redirect form the first URL to the second:

RewriteCond %{QUERY_STRING} ^typ=([a-zA-Z0-9_-]+)$
RewriteRule ^cat\.php$ cat/%1/? [R,L]

If you want to edit the links in your HTML you could try mod_substitute (make sure that mod_filter is also enabled):

AddOutputFilterByType SUBSTITUTE text/html
Substitute s|/?cat\.php\?typ=([a-zA-Z0-9_-]+)|/cat/$1/|i

if you type manually your new link it works right?

simply have your html link point to "Politics.html" instead of "cat.php?typ=Politics" htaccess will take care of the rest