I want the URL
www.mysite.com/page.php?q=1&n=2
to be shown in the broser's address bar as
www.mysite.com/albums/ or www.mysite.com/albums.php
but still load the same page with all the variables can anyone tell me how can this be done?
PS I didn't knew where to post this question thus apologizing if it doesn't belong here
How to display a different URL than the actual?
Moved to PHP Coding forum.
One obvious way would be for page.php to use $GET['q'] and $GET['n'] to determine that the user should be re-directed (e.g., with a location [man]header[/man]) to /albums/.
not what I meant...I want when the address www.mysite.com/index.php?q-11&v=13 is called the browser's URL to be changed in www.mysite.com/index and still to load the www.mysite.com/index.php?q-11&v=13 this is done somehow with .htaccess still digging...
There doesn't appear to be a correlation to the address of the page (with the query string) and the address of the page you want it shown from.
.htaccess isn't very dynamic in the sense that it cannot look your ID numbers up in a database to find where you want them to be pointed from.
It is very capable, however, of taking URL strings like /controller/page/section that points to controller.php?p=page&s=section. So maybe you want to do it in a way similar to that?
do it all behind the scenes with $_POST?
This is an answer to the original post. This is how you would redirect "albums/" to use "page.php?q=1&n=2":
RewriteEngine On
RewriteRule ^albums/$ page.php?q=1&n=2 [L]
Ofcourse you have to define all the pages that you use with that. Better would be that you define all files except media files to be redirected to index.php and then do the actions according to that. That way you could easily define nice lookin urls using $_SERVER['REQUEST_URI']. This is how most frameworks work and thats what madwormer2 was saying also.
Heres a nice roundup of the rewrite and comes very handy from time to time:
http://www.addedbytes.com/apache/mod_rewrite-cheat-sheet/
I this way when the user types "albums/" the server will see "page.php?q=1&n=2" I also want when the user types page.php?q=1&n=2 this page to be loaded but in th eurl to be displayed the "albums/"
Why not simply set up the href to "albums/" so the user will both see "albums/" and be redirected to the correct page using the .htaccess method