Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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]
like image 872
Rubentje Avatar asked May 25 '26 05:05

Rubentje


1 Answers

Found the answer...

Add this to .htaccess:

RewriteCond %{REQUEST_URI} !^(/assets)

like image 103
Rubentje Avatar answered May 26 '26 18:05

Rubentje



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!