Virtual URL with PHP?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • NoComment
    New Member
    • Jun 2007
    • 16

    Virtual URL with PHP?

    Hi there!

    Is it possible, that every request to your website executes only one and the same PHP script everytime?

    An example:







    will all execute a single script, let's say "index.php" , which somehow has access to the parameters (none, thread-183, article-92, start, files/image.jpg). Is something like this possible? If so, how and how can "index.php" then catch those parameters?

    Thanks in advance for any help. :)
  • mwasif
    Recognized Expert Contributor
    • Jul 2006
    • 802

    #2
    Apache mod_rewrite does this trick and this is called URL rewriting. You can google on these keywords and you will find a lot of stuff.

    After enabling mod_rewrite in Apache, you create rewrite rules to accomodate such URLs. A sample .htaccess rule can be

    RewriteEngine On
    RewriteRule ^thread-([0-9]+)$ index.php?modul e=thread&id=$1 [L]

    Comment

    • NoComment
      New Member
      • Jun 2007
      • 16

      #3
      Originally posted by mwasif
      Apache mod_rewrite does this trick and this is called URL rewriting. You can google on these keywords and you will find a lot of stuff.

      After enabling mod_rewrite in Apache, you create rewrite rules to accomodate such URLs. A sample .htaccess rule can be

      RewriteEngine On
      RewriteRule ^thread-([0-9]+)$ index.php?modul e=thread&id=$1 [L]
      Thank you so much! It seems like this is exactly what I need. I'll go google for it. If something I don't understand pops up, I'll just give a shout ;).

      Comment

      • kovik
        Recognized Expert Top Contributor
        • Jun 2007
        • 1044

        #4
        If you are using Apache 1.3 or some other version below v2, be aware that you can't use PCRE, but have to settle for POSIX. If you aren't familiar with POSIX, I wrote a tutorial on parsing clean URLs through PHP if you're interested.

        Comment

        • NoComment
          New Member
          • Jun 2007
          • 16

          #5
          Originally posted by volectricity
          If you are using Apache 1.3 or some other version below v2, be aware that you can't use PCRE, but have to settle for POSIX. If you aren't familiar with POSIX, I wrote a tutorial on parsing clean URLs through PHP if you're interested.
          Okay, I'll have a look into that, too. Thank you all so much for your help :)

          Comment

          Working...