Apache Rewrite: a simple exception does not work for image types

This question seems simple to me, although I cannot get it to work.

I am trying to make simple rewrite for all requests except certain types of images.

Three VERY important clarifications ...

1.) This is done with the .htaccess file in the image directory, access to which from the browser is located at example.com/images/ , therefore the .htaccess file is located in public_html / images / .htaccess locally.

2.) This solution should go well with the work that I received from other people in this task ...

Apache Rewrite: HTTP host-based image catalog

3.) I use shared hosting, not VPS or dedicated, so my access is limited; I know that it will not be difficult in any way.

I tried the following (along with its modifications) without success ...

public_html / images / .htaccess

RewriteEngine on RewriteRule !\.(gif|jpg|png)$ index.php?q=$1 [L] 

I will be happy to make clarifications, as well as vote and accept a working answer. I think I probably just missed something simple here ...

-one
source share
1 answer

I assume that you are trying to redirect everything to index.php when the request to the images folder is not a call to the image file.

Try the following:

 RewriteEngine on RewriteCond %{REQUEST_URI} !\.(gif|jpg|png)$ [NC] RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] 
+2
source

Source: https://habr.com/ru/post/1394893/


All Articles