htaccess not redirect automatically

Discussion in 'PHP' started by kawie, Nov 22, 2009.

  1. #1
    hi

    please look at this url

    when evry body visit

    http://www.noorksa.com/download.php?filename=baa6a5a295.zip

    it's not redirect automatically to

    http://www.noorksa.com/dbaa6a5a295.zip.html

    what am i supposed to do??

    plz help me

    what can i do ??
     
    kawie, Nov 22, 2009 IP
  2. phpPig

    phpPig Peon

    Messages:
    128
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Is the filename a coming from query on the database or just a single file that needs the link changed?
     
    phpPig, Nov 23, 2009 IP
  3. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #3
    You do the redirect using htaccess? I don't think it will work for urls with query string.
     
    ads2help, Nov 23, 2009 IP
  4. kawie

    kawie Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    phpPig thanks for replay

    the filename coming from query ..

    i think there some php code put it in the file "download.php"

    but what is it ?? :(

    ...

    ads2help

    thanks for replay

    yes am using htaccess for do that

    take a look here

    Options +FollowSymlinks
    
    RewriteEngine on
     
    RewriteRule ^d([A-Z,a-z,0-9,.,\_]*).html$ download.php?filename=$1 [L]
    PHP:
    please i need your's help
     
    kawie, Nov 23, 2009 IP
  5. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #5
    Looks like I misunderstood you.

    You want to redirect http://www.noorksa.com/dbaa6a5a295.zip.html to http://www.noorksa.com/download.php?filename=baa6a5a295.zip

    ---

    Your syntax is wrong. Try this.

    Options +FollowSymlinks
    
    RewriteEngine on
     
    RewriteRule ^d([A-Za-z0-9.,_]*)\.html$ what.php?filename=$1 [L]
    Code (markup):
    If you need simpler URLs, read this seo friendly url with htaccess.
     
    ads2help, Nov 23, 2009 IP
  6. kawie

    kawie Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    no ads2help i need redirect http://www.noorksa.com/download.php?filename=baa6a5a295.zip to http://www.noorksa.com/dbaa6a5a295.zip.html

    automatically

    all i need is redirect automatically

    but how

    there some php code must i put it in download.php file ??
     
    kawie, Nov 23, 2009 IP
  7. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #7
    But your htaccess rules show the opposite of what you are trying to do.

    If you need to redirect http://www.noorksa.com/download.php?filename=baa6a5a295.zip to http://www.noorksa.com/dbaa6a5a295.zip.html, you don't need htaccess, just php.

    The php codes you need to put in download.php:

    header('location: http://www.noorksa.com/d'.$_GET['filename'].'.html');
    PHP:
     
    ads2help, Nov 23, 2009 IP
  8. kawie

    kawie Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    it's too slow and page not found after slow :(

    thanks ads2help
     
    kawie, Nov 23, 2009 IP
  9. kawie

    kawie Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    please look example

    see that url

    http://forum.e7s.com/showthread.php?t=488

    when u visit it .. it's redirect automatically to

    http://forum.e7s.com/t488.html

    i need to know how ??

    and thanks
     
    kawie, Nov 23, 2009 IP
  10. phpPig

    phpPig Peon

    Messages:
    128
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Okay, not sure if this will work but this is what I always have used in every script that I have ever written. The only real difference that I can really see is that you may define the string .html$ as .zip.html$.

    Example

    Options +FollowSymlinks

    RewriteEngine on

    RewriteRule ^d([A-Z,a-z,0-9,.,\_]*).zip.html$ download.php?filename=$1 [L]


    Try that and see how that turns out.
     
    phpPig, Nov 23, 2009 IP
  11. kawie

    kawie Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    thanks but the filename have zip also rar & 3gp not zip only

    thanks again phpPig
     
    kawie, Nov 23, 2009 IP
  12. phpPig

    phpPig Peon

    Messages:
    128
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Options +FollowSymlinks

    RewriteEngine on

    RewriteRule ^d([A-Z,a-z,0-9,.,\_]*).([0-9,a-z]+).html$ download.php?filename=$1 [L]

    Maybe that will work for you.
     
    phpPig, Nov 23, 2009 IP
  13. phpPig

    phpPig Peon

    Messages:
    128
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #13
    If this doesn't work and you don't have too many filenames, make separate entries into the .htaccess file. such as:

    Options +FollowSymlinks

    RewriteEngine on

    RewriteRule ^d([A-Z,a-z,0-9,.,\_]*).zip.html$ download.php?filename=$1 [L]
    RewriteRule ^d([A-Z,a-z,0-9,.,\_]*).3gp.html$ download.php?filename=$1 [L]
    RewriteRule ^d([A-Z,a-z,0-9,.,\_]*).rar.html$ download.php?filename=$1 [L]


    I use this feature on a few of the scripts that I have written for search engine optimization for different keywords.
     
    phpPig, Nov 23, 2009 IP
  14. kawie

    kawie Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    it's dosen't work ..

    not redirect automatically yet ... i think not from htaccess .. there some php code to do that ..

    thanks phpPig to trying
     
    kawie, Nov 23, 2009 IP
  15. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #15
    If you need to redirect http://www.noorksa.com/download.php?filename=baa6a5a295.zip to http://www.noorksa.com/dbaa6a5a295.zip.html, you don't need htaccess, just php.


    Is it because you don't have the file called dbaa6a5a295.zip.html?
     
    ads2help, Nov 23, 2009 IP
  16. kawie

    kawie Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16
    yes i don't have but what can i do for do that ??

    is there no slove ??

    thanks for comming
     
    kawie, Nov 23, 2009 IP
  17. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #17
    This is the thing I don't understand, if you do not have that file, why did you want to do the redirect?? :confused:
     
    ads2help, Nov 23, 2009 IP
  18. kawie

    kawie Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #18
    so sorry for that . you right

    i need mod writer .. short url

    that what i need forgivme for my mistake

    this is first time i write here and my english it's too bad :(

    thanks ads2help
     
    kawie, Nov 23, 2009 IP