SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Evangelist
    Join Date
    Mar 2011
    Location
    Bellingham, WA
    Posts
    450
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    CSS and JS shouldn't be re-writing

    Hello!

    I'm taking my first stab at creating a mini-MVC to better understand the concepts behind such a design. I'm using:

    Code:
    RewriteEngine On
    RewriteCond %[REQUEST_FILENAME] !-d
    RewriteCond %[REQUEST_FILENAME] !-f
    RewriteCond %[REQUEST_FILENAME] !-l
    
    
    RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
    to rewrite my URLS and it works great except for my css and js files. I thought that the "!-f" line would take care of these, but if I run a script with:

    HTML Code:
    <link rel="stylesheet" href="public/css/default.css" />
    then, I think that it's still treating my link as something to be rewritten. Any help with this would be appreciated.

  2. #2
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    Posts
    1,311
    Mentioned
    19 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by kreut View Post
    I thought that the "!-f" line would take care of these
    Indeed it should. Are you sure the CSS URL is correct? Perhaps it should be /css/default.css? What makes you think it's rewriting your link?
    "First make it work. Then make it better."

  3. #3
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    Posts
    1,311
    Mentioned
    19 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by kreut View Post
    [CODE]RewriteEngine On
    RewriteCond %[REQUEST_FILENAME] !-d
    RewriteCond %[REQUEST_FILENAME] !-f
    RewriteCond %[REQUEST_FILENAME] !-l
    I just noticed a syntax error. You should be using curly braces, not square brackets.

    %{REQUEST_FILENAME}
    "First make it work. Then make it better."

  4. #4
    SitePoint Evangelist
    Join Date
    Mar 2011
    Location
    Bellingham, WA
    Posts
    450
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    That fixed it! And, for someone who doesn't typically work with Rewrites, for future debugging of this sort, is there a file that I could have viewed that would have told me that there was a syntax error?

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

    No, there isn't. The best thing you can do is SEE any redirection by using the [R=301] flag to test.

    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

  6. #6
    SitePoint Evangelist
    Join Date
    Mar 2011
    Location
    Bellingham, WA
    Posts
    450
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the tip!


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
  •