S
S
SET12020-09-29 17:23:18
htaccess
SET1, 2020-09-29 17:23:18

How to compose .htaccess correctly?

I need to redirect all requests to index.php, except for those that start with /static, they should be silently (without changing the URL) redirected to /src/App/public/static/.

There is this code:

RewriteEngine on

RewriteRule ^/static/(.*)$ /src/App/public/static/$1 [L,NC]
RewriteRule ^((?!index\.php).+)$ /index.php [L]


but it doesn't work - all request goes to index.php

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2020-09-29
@SET1

RewriteCond %{REQUEST_FILENAME} !-f
#если это не файл
RewriteCond %{REQUEST_FILENAME} !-l
#  и если это не линка
RewriteCond %{REQUEST_FILENAME} !-d
# и это не директория
RewriteCond %{REQUEST_FILENAME} !/bitrix/urlrewrite.php$
# и это не нужный нам файл, от цикла
RewriteRule ^(.*)$ /bitrix/urlrewrite.php [L]
# то перенапраить все это лядство на него ;)

Is the logic clear?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question