FAQ: mod_rewrite, 301 redirects, and optimizing Apache.

Discussion in 'Apache' started by Nintendo, Jul 30, 2005.

  1. The Webmaster

    The Webmaster IdeasOfOne

    Messages:
    9,516
    Likes Received:
    718
    Best Answers:
    0
    Trophy Points:
    360
    #341
    Ohh heck!!

    Okay got the point.
    thanks for the help Nintendo and Vishwa
     
    The Webmaster, Jun 24, 2006 IP
  2. amitpatel_3001

    amitpatel_3001 Results Follow Patience

    Messages:
    14,074
    Likes Received:
    1,178
    Best Answers:
    0
    Trophy Points:
    430
    #342
    Did you need this URL's structure for the Joomla site?
     
    amitpatel_3001, Jun 26, 2006 IP
  3. The Webmaster

    The Webmaster IdeasOfOne

    Messages:
    9,516
    Likes Received:
    718
    Best Answers:
    0
    Trophy Points:
    360
    #343
    no.................
     
    The Webmaster, Jun 26, 2006 IP
  4. joewills

    joewills Peon

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #344
    I would like to point this url:

    /0007149921/The-Pale-Horseman.php to /product.php?id=$1

    Although the name of the file could be any e.g. /0007149921/The-random-name.php - I am only interested in the id / number part for url

    My lame attempt:

    RewriteRule ^([A-Za-z0-9]+)/$ /product.php?num=$1


    Any clues?

    Thanks for any help,

    Joe
     
    joewills, Jun 26, 2006 IP
  5. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #345
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)/$ product.php?num=$1 [L]
     
    Nintendo, Jun 26, 2006 IP
  6. joewills

    joewills Peon

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #346
    Thanks for the swift reply. I have tried your answer and no joy. Does the [^.] mean any character(s)? If this is so, then my solution and yours are very similar

    RewriteRule ^([A-Za-z0-9]+)/$ /product.php?num=$1
    works for the url: mydomain.com/0007149921/

    but not for mydomain.com/0007149921/The-Pale-Horseman.php

    Is there somekind of wildcard symbol i need?

    "RewriteRule ^([A-Za-z0-9]+)/$ /product.php?num=$1"

    doesn't $ symbolise the end of the string...... ??

    Thanks for help,

    Joe
     
    joewills, Jun 26, 2006 IP
  7. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #347
    Try (.*). If that doesn't work try a test

    XBitHack Full
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^index\.page$ index.html [L]

    with index.html being the index file and then go to domain.com/index.page and see if it shows the index page.
     
    Nintendo, Jun 26, 2006 IP
  8. trung

    trung Peon

    Messages:
    10
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #348
    Hi all,

    All pages in test enviroment are OK, but doesn't work after uploaded in real enviroment?

    Anybody can help me? Thank a lot.
     
    trung, Jul 6, 2006 IP
  9. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #349
    E-mail your web host. What's the code you got right now from posting at webmasterworld.com/forum92/?
     
    Nintendo, Jul 6, 2006 IP
  10. rlynch

    rlynch Peon

    Messages:
    248
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #350
    is the [L] required after every rule?

    i only have it after my first rule and things seem to be working

    i would change it but i dont want to fix what isnt broken

    thanks
     
    rlynch, Jul 11, 2006 IP
  11. Shoemoney

    Shoemoney $

    Messages:
    4,474
    Likes Received:
    588
    Best Answers:
    0
    Trophy Points:
    295
    #351
    this is one of the greatest threads ever
     
    Shoemoney, Jul 11, 2006 IP
  12. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #352
    This thread and the AdSense/YPN FAQs are just to help save me from being banned for being an annoying wacko!!! :D:D:D:D

    I've done mod_rewrite with out the [L].
     
    Nintendo, Jul 11, 2006 IP
    iqra_psh likes this.
  13. iqra_psh

    iqra_psh Active Member

    Messages:
    992
    Likes Received:
    113
    Best Answers:
    0
    Trophy Points:
    85
    #353
    Best thread and learn at least some thing about mod_rewrite.

    BTW any difference between ForceType and Mod_rewrite OR its same thing,
    If there is difference what are pros and cons of each while comparing.
    Thanks Nintendo for Super thread.
     
    iqra_psh, Jul 19, 2006 IP
  14. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #354
    There's a big difference between changing the URLs and for example making all files be images.

    # force all files to be image/gif:
    <Location /images>
    ForceType image/gif
    </Location>
     
    Nintendo, Jul 19, 2006 IP
  15. mnazman

    mnazman Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #355
    hello..anybody help me :0

    i want to change from

     
    mnazman, Jul 21, 2006 IP
  16. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #356
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^browse/([^.]+)\.html$ index.php?browse=/$1/ [L]

    or if that doesn't do it....

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^browse/([^.]+)([^.]+)/([^.]+)/([^.]+)/([^.]+)/([^.]+)\.html$ index.php?browse=/$1/$2/$3/$4/$5/ [L]
    RewriteRule ^browse/([^.]+)([^.]+)/([^.]+)/([^.]+)/([^.]+)\.html$ index.php?browse=/$1/$2/$3/$4/ [L]
    RewriteRule ^browse/([^.]+)([^.]+)/([^.]+)/([^.]+)\.html$ index.php?browse=/$1/$2/$3/ [L]
    RewriteRule ^browse/([^.]+)([^.]+)/([^.]+)\.html$ index.php?browse=/$1/$2/ [L]
    RewriteRule ^browse/([^.]+)\.html$ index.php?browse=/$1/ [L]
     
    Nintendo, Jul 21, 2006 IP
  17. mnazman

    mnazman Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #357
    TQ nitendo, i'm follow your suggestion but still not function :confused:
     
    mnazman, Jul 22, 2006 IP
  18. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #358
    Nintendo, Jul 22, 2006 IP
  19. mnazman

    mnazman Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #359
    yes..it is run well
     
    mnazman, Jul 22, 2006 IP
  20. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #360
    Nintendo, Jul 22, 2006 IP