I would like to know if this, http://www.cpleurope.com/news/207/, is possible to do with php or maybe with a webserver setting?

What I mean is, I believe it opens a file named news and takes 207 in as the news-id instead of news.php?id=207 as we're used to.
But how to do that?

Sorry for my bad english! 😮

    I think there is a module you can install to allow you to do that. I forgot where I read about it at...

      Originally posted by Pests
      I think there is a module you can install to allow you to do that. I forgot where I read about it at...

      would that be a php or apache module?

        You dont need any module -- use PHP predefined variable $_SERVER['QUERY_STRING']

          First, make an .htaccess file that has this in it:

          <FilesMatch "news$">
          ForceType application/x-httpd-php
          </FilesMatch>

          Now, whenever you visit http://www.example.com/news/ It'll fun that script. Next you need to write a small script to read in and parse out the query string, so that you can get the news ID.

          You can do this by explode()ing $SERVER['PHP_SELF'] I belive, if that doesn't show it, use $SERVER['REQUEST_STRING'] or some such, its one of the PHP predefined variables.

          Hope that helps!

            Oh, and no, you don't need any extra modules to do it that way.

            Alternatively you could use the Apache module mod_rewrite. Note also this will only work on *nix boxes, not on Windows.

              Thanks everyone

              I've tried exploding $SERVER['QUERY_STRING'] before but then I still needed the "?", never thought of using $SERVER['PHP_SELF'], will try it if not...

              Anyone here can help me more specific with mod_rewrite because I read some documentation and I can't say I understood alot...

                Write a Reply...