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/.

    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?

      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/"

          2 months later

          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

            Write a Reply...