skip to Main Content

I use the following .htaccess file to send all my requests to the index file.
But now I would like to ignore everything that comes from the /static folder.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

So here’s the thing:

- index.php
- static/
----img
--------bg.jpg
----css
--------main.css

Currently it is so that on subpages of the style and the images can no longer be loaded. And I would like to renounce the use of complete paths.

2

Answers


  1. Well, you need to add an exception, right?

    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^/static/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
    
    Login or Signup to reply.
  2. You may try this rule:

    RewriteEngine on
    
    RewriteCond %{THE_REQUEST} !/static/ [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ index.php [L]
    

    Using THE_REQUEST is preferred for negative conditions as THE_REQUEST variable is not overwritten with other rules.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search