A
A
Argentium2020-04-19 17:32:20
htaccess
Argentium, 2020-04-19 17:32:20

How to make a beautiful link from a subdirectory?

Hello, you need to make the URL instead of site.ru/pages/news.php be site.ru/news
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Viktor Taran, 2020-04-22
@shambler81

This should not be dealt with entirely by .htaccess, this should be done by the CNC to which .htaccess should already be transferred
. Only the kernel knows what kind of entity this page is, whether it is physical or not, and so on.
that is, the url can be prepared, but the second thing you will encounter is 404 because this page does not exist.
By this
URL prepares .htaccess and the kernel answers I have it.
Here is an example.

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

When all this is already working and the cnc can already physically give such a url, you can stir up the redirect, but as a rule, the cnc itself is occupied by this, in the settings of the component (in this engine) it is already written how the urls are generated.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question