hi i need to change the url from

www.domainname.com/page.php?i=1&sid=7

to

www.domainname.com/page/i=1&sid=7

Place this in the .htaccess file that is in the same directory is the homepage:

RewriteEngine On
RewriteRule ^([^.]+)\/(.*)$ $1.php?$2

Edit:
I discover that the script I posted takes over all real directories so you will need to specify each directory like the following:

RewriteEngine On
RewriteRule ^page\/(.*)$ $1.php?$2
RewriteRule ^page2\/(.*)$ $1.php?$2
RewriteRule ^page3\/(.*)$ $1.php?$2
RewriteRule ^blog\/(.*)$ $1.php?$2

And so on.

hi i tried like this

htaccess file code

RewriteEngine On
RewriteRule ^page$ test.php?$1

test.php code

<?php
echo $_SERVER['PHP_SELF'];
echo "<hr>";
print_r($_GET);
?>

output
when i typed: http://localhost/hi_test/page?i=5&sid=4

/hi_test/test.php
--------------------------------------------------------------------------------
Array ( )

i'm unable to get the get elements

Opps, I was up late when writing that and forgot to put in the brackets. So a better example that should work is as follows:

RewriteEngine On
RewriteRule ^(page)\/(.*)$ $1.php?$2
RewriteRule ^(page2)\/(.*)$ $1.php?$2
RewriteRule ^(page3)\/(.*)$ $1.php?$2
RewriteRule ^(blog)\/(.*)$ $1.php?$2

or as your example should show:

RewriteEngine On
RewriteRule ^(var=page)$ test.php?$1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.