Howto Use URL Rewriting for PHP Web Applications


Options +FollowSymlinks
RewriteEngine on
RewriteRule ^files/(.+)/(.+).tar.gzip download.php?section=$1&file=$2 [nc]

Would allow you to present a link as:

http://site.com/files/games/bubble.tar.gzip

and in the background have that translated to..

http://site.com/download.php?section=games&file=bubble

Related posts:

  1. .htaccess Generator
  2. Compressing mysqldump output – mysql, gzip, bzip2 and LZMA (7z)
  3. Howto Secure Apache
  4. Ubuntu Howto: Install Sun Java
  5. Howto: Office 2007 on Linux with Wine
  6. Monitor Configuration Files
  7. Howto Install Sun Java on Debian Etch
  8. iPhone Background Package
  9. Seamless Windows Applications on Ubuntu Linux Using VirtualBox
  10. Migrate existing Ext3 filesystems to Ext4

Popular Related Items »

8 Comments »

  1. samantha said,

    April 7, 2008 @ 19:07

    Dear Sir,

    I am very new to php programming. I want to rewrite my url. I could not have any hint from the above code. Is there anyone to help me with the full code/process. I will be very thankful.

    Regards
    Samantha

  2. PHP Coder said,

    April 8, 2008 @ 8:59

    Hello Samantha,

    The shown example will require that you create a PHP file called download.php and that this file use two variables from the querystring; section and file.

    And add the folowing code to your .htaccess file

    Options +FollowSymlinks
    RewriteEngine on
    RewriteRule ^files/(.+)/(.+).tar.gzip download.php?section=$1&file=$2 [nc]

  3. nani said,

    June 19, 2008 @ 8:30

    Hi

    I want to rewrite url for site http://www.pakpressads.com/.

    Can u help me in this

    Regards

  4. Aisha Junejo said,

    July 26, 2008 @ 7:08

    Hi
    I have some problem regarding .htaccess,I have to do folder based Url rewriting in my site.I have also tried the 3rd rule that you have written.
    RewriteRule ^([a-zA-Z0-9_-]+)$ user.php?username=$1
    RewriteRule ^([a-zA-Z0-9_-]+)/$ user.php?username=$1
    But when I use it on any page of my site,all the images on that page are not being displayed.
    Can you please help me a little to get out of this problem?

  5. Neeraj said,

    September 19, 2008 @ 6:54

    Ok its work..
    but how can i change uri in my files automatic?
    please help me.

  6. Rahul said,

    March 5, 2009 @ 10:48

    I have the same problem like

    Aisha Junejo said
    Is there any solution Please

  7. Rahul said,

    May 4, 2009 @ 10:51

    Very nice blog.keep it up.

  8. Howto Use URL Rewriting for PHP Web Applications said,

    June 1, 2009 @ 17:48

    [...] from: Howto Use URL Rewriting for PHP Web Applications Share and [...]

RSS feed for comments on this post · TrackBack URI

Leave a Comment