SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    Not yet perfect mattalexx's Avatar
    Join Date
    Oct 2005
    Location
    Taos, NM, US
    Posts
    441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problems with 301 mod_rewrite

    Why is this working:
    Code:
    RewriteRule ^disthumbs.php$ pages/front/item_list.php [QSA,L]
    ... and this is not?
    Code:
    RewriteRule ^disthumbs.php$ pages/front/item_list.php [QSA,L,R=301]
    Matt Alexander
    Alexander Site Design

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,672
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    matt,

    Both have the same (minor) problems but the second one is supposed to show the redirection.
    Code:
    RewriteRule ^disthumbs.php$ pages/front/item_list.php [QSA,L,R=301]
    1. ^ can only be used for Apache 2.x - it will not match with Apache 1.x because that version requires you to include the leading / of the {REQUEST_URI} string.

    2. . (in disthumbs.php) needs to be escaped to match ONLY the dot character, otherwise it matches ANY character.

    3. We have to assume that there are no extra spaces in your .htaccess lines AND that disthumbs.php exists at the directory level of your .htaccess file. We must further assume that item_list.php exists two levels down in the pages/front/ subdirectory.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    Not yet perfect mattalexx's Avatar
    Join Date
    Oct 2005
    Location
    Taos, NM, US
    Posts
    441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks dklynn, I'll try that.

    Little by little, I improve at this very specific language.
    Matt Alexander
    Alexander Site Design

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,672
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    matt,

    While gross overkill (full regex), Mastering Regular Expressions by Friedl is the "bible" for regex and will tell you everything there is to know - except that only a subset is available in mod_rewrite. Bowen's The Definitive Guide to Apache mod_rewrite is straight to the point but written mostly from the standpoint of modifying httpd.conf (where it should be located, if possible, but this is most often not possible). Therefore, I must recommend my "summarization with examples" which are in the tutorial Article in my signature (and you know where to come to ask questions about the content there).

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •