SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Rewrite urls.. except files.. except dir ? :P

    is it possible to give access to directory / files except files inside /themes directory.. then still rewrite to index.php ?

    Code:
    Options +FollowSymLinks
    IndexIgnore */*
    RewriteEngine on
    
    # if a directory or a file exists, use it directly
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    
    # otherwise forward it to index.php
    RewriteRule . index.php
    Go visit my site you know you want to
    http://con.cept.me

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

    Yes, but ONLY if the file/directory exists.

    BTW, the regex for the RewriteRule will not match just a domain request (without making the {any character} optional) so you must rely on the DirectoryIndex to get to index.php.

    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
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    63
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how?

    Maybe I am not explaining it right..

    How can I add an exception to this line:

    RewriteCond %{REQUEST_FILENAME} !-d
    Go visit my site you know you want to
    http://con.cept.me

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

    You DON'T! You merely add another exception with RewriteCond %{REQUEST_URI} !themes/ either before or after the other RewriteCond (they're ANDed so order makes no logical difference).

    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

  5. #5
    SitePoint Enthusiast
    Join Date
    May 2006
    Posts
    78
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    Thanks again David, this is exactly what I came looking for today.
    Using something similar to this (for example)
    Code:
    RewriteCond $1 !^(ContactoŽEn/Contact)\.html$ [NC]
    wasn't working out (after being modified a bit)
    Your way:
    Code:
    RewriteCond %{REQUEST_URI} !example/
    Worked the on the first try.


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
  •