D
D
danyarob2021-10-24 22:36:33
htaccess
danyarob, 2021-10-24 22:36:33

Am I converting to cnc correctly?

I have a directory directory, it has a file items.
I need to do /directory/items/10 instead of /directory/items?id=10

In htaccess I set the setting

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /directory/items [L]


If I follow the link /directory/items/10, it displays the error "Internal Server Error", although in fact there should be a 404 error, tell me, maybe I'm doing something wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2021-10-26
@shambler81

uh bro
you didn't create a cnc
you created a redirect to the place where requests will be processed
Here is an example cnc

RewriteEngine On
#Включается 1 раз  на файл активирует редиректы
RewriteCond %{REQUEST_FILENAME} !-f
# если это не файл
RewriteCond %{REQUEST_FILENAME} !-l
# и если это не  линка
RewriteCond %{REQUEST_FILENAME} !-d
# и если это не директория, то есть не физически существующие файлы и папки, то есть по факту 404тые как у тебя сейчас
RewriteCond %{REQUEST_FILENAME} !/bitrix/urlrewrite.php$
# и не сам файл отвечающий за создание ЧПУ
RewriteRule ^(.*)$ /bitrix/urlrewrite.php [L]
#  если все это удовлетворено то сделать редирект на файл который отвечает за создание ЧПУ

Actually, after that, it opens your file, which receives a URL that does not physically exist, but it has a correspondence of this GET parameter to the necessary actions, for example, display the directory in this perspective.
Your php file generates the desired page and returns it with a 200 code.
All you have done is collect all these requests and send it to this link
and what do you expect? handle then who will you have there?
Read here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question