[ASK] How to make link like this http://asda?asdsd

Discussion in 'PHP' started by so_sweet, Aug 27, 2010.

  1. #1
    Hi there
    i just wonder to know about how to make link like this exmple :

    i have link :
    http://halaman.com/download.php?id=123abcd
    Code (markup):
    and want to make that link to :

    http://halaman.com?123abcd
    Code (markup):
    how?
     
    so_sweet, Aug 27, 2010 IP
  2. GeekOnline

    GeekOnline Peon

    Messages:
    58
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    U have to use the code from download.php in index.php

    in the sense the get method in index.php

    Hope u got what i mean
     
    GeekOnline, Aug 27, 2010 IP
  3. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #3
    For this /download.php?id=123abcd to this /123abcd, create a .htaccess file and place the following code into it and put the file into your root/ www public_html or htdocs folder.

    
    Options +FollowSymLinks
    
    RewriteEngine on
    
    RewriteBase /
    
    RewriteCond %{REQUEST_FILENAME} !-d
    
    RewriteCond %{REQUEST_FILENAME} !-f
    
    RewriteRule (.[^/]*) /download.php?id=$1 [NC,L]
    
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /download\.php\?id=(.[^/]*)\ HTTP/
    
    RewriteRule ^download\.php$ /%1? [R=301,L]
    
    PHP:
     
    MyVodaFone, Aug 29, 2010 IP
  4. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #4
    If you want to avoid htaccess, you will need to do something like this:

    http://halaman.com?Download*123abcd

    And on topmost of your index.php you do:

    
    list($page,$_GET['ID']) = explode('*',$_SERVER['QUERY_STRING']);
    if($page == 'Download')
    {
        include('download.php');
        die();
    }
    
    PHP:
     
    ThePHPMaster, Aug 29, 2010 IP
  5. so_sweet

    so_sweet Member

    Messages:
    234
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    28
    #5
    avoiding .htaccess if just i'm not use linux server, thanks for u both, appreciated
     
    so_sweet, Sep 2, 2010 IP