SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2007
    Posts
    170
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Rewrite rule for only index

    Hi, could use some help here. Currently I have the following rules which redirects all request (http://domain.com/test) to index.php?pathInfo=test

    PHP Code:
    RewriteEngine On
    RewriteCond 
    %{REQUEST_FILENAME} !-f
    RewriteCond 
    %{REQUEST_FILENAME} !-d

    RewriteRule 
    ^(.*)$ index.php?pathInfo=$[PT,L
    Is there a way whereby if I request something like:

    http://domain.com/other.php?id=blah

    htaccess will ignore and let it passthru as a normal script request? Any help is greatly appreciated.
    I Dunno LOL \(_o)/

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

    I believe that your use of the PassThrough flag is incorrect - I would have simply used [L].

    Yes, include a test (RewriteCond) which specifies NOT id=blah then use your RewriteRule.

    WARNING: [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]

    Moreover, it is the easiest way for hackers to gain access to your server. NEVER redirect an unverified $_GET variable like this!

    You might benefit from reading the mod_rewrite tutorial linked in my signature as it contains explanations and sample code. It's helped may members and should help you, too.

    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
  •