SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Who turned the lights out !! Mandes's Avatar
    Join Date
    May 2005
    Location
    S.W. France
    Posts
    2,496
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Mod Rewrite help

    Hi people

    Having a sticky time with a simple mod rewrite, should be easy but I just cant seem to get it to work tonight.

    My incoming URL will look like

    I want it to rewrite into

    ie the whole query is to passed as the value of 'slug' including any and all backslashes

    Ive tried

    Code:
    RewriteEngine on
    RewriteCond %{QUERY_STRING} ^$
    RewriteRule ^/(.*)$ index.php?slug=$1
    and variants to no avail

    TIA
    A Little Knowledge Is A Very Dangerous Thing.......
    That Makes Me A Lethal Weapon !!!!!!!!

    Contract PHP Programming

  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)
    Mandes,

    Too much wrong for me to correct now - look at the tutorial in my signature and I'll get back shortly.

    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
    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)
    Okay, how is pagename defined? You've got to specify that without being able to conflict with actual (existing) pagenames.

    Then, why kill an existing query string?

    Then, ^/ will only work on Apache 1.x servers, not on Apache 2.x servers. That's been the case for several years now.

    Finally, what do you expect (.*) to match? It will match EVERYTHING (or NOTHING) and that's absolutely ridiculous code to use. It's so bad that I have created a Standard Rant to use:

    [rant #1]
    The use of "lazy regex," specifically the EVERYTHING atom, (.*), and its close relatives, is the NUMBER ONE coding error of newbies BECAUSE it is "greedy." Unless you provide an "exit" from your redirection, you will ALWAYS end up in a loop!
    [/rant #1]

    Again, have a look at the tutorial and you'll learn how to do it correctly. Many have already.

    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
  •