Rubentje
Rubentje

Reputation: 128

htAccess redirect all .php except assets folder

I want to redirect all .php scripts to index.php with htaccess. Except the scripts that are inside the /assets/ folder.

For example:

   /test.php                         ->    /index.php
   /folder/test.php                  ->    /index.php
   /assets/test.php                  ->    /assets/test.php
   /assets/folder/folder/test.php    ->    /assets/folder/folder/test.php

This is my current htaccess file:

RewriteEngine on
RewriteCond %{REQUEST_URI} !(\.png|\.jpg|\.gif|\.jpeg|\.bmp|\.css|\.js|\.woff|\.woff2|\.map|\.ico|\.map)$
RewriteCond $1 !^(index\.php|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

Upvotes: 3

Views: 1022

Answers (1)

Rubentje
Rubentje

Reputation: 128

Found the answer...

Add this to .htaccess:

RewriteCond %{REQUEST_URI} !^(/assets)

Upvotes: 1

Related Questions