N
N
Nikolay2017-01-12 18:01:44
PHP
Nikolay, 2017-01-12 18:01:44

How to remove the trailing slash in the address bar?

Greetings!
We have, say, the following site structure on Bitrix:

/poezda/index.php
...
/kontakty.php

And let's say this menu:
<a href="http://site.ru/poezda">Поезда</a>
    <a href="http://site.ru/poezda/poezd1">Поезд 1</a>
    <a href="http://site.ru/poezda/poezd2">Поезд 2</a>
<a href="http://site.ru/kontakty">Контакты</a>

<!-- В конце ссылок нет слешей -->

When switching, links are added to the end of the address bar with a slash, i.e. it turns site.ru/kontakty/
out Nothing has changed when adding the rule to urlwrite.php :
$arUrlRewrite = array(
  array(
    "CONDITION" => "#^/poezda#",
    "PATH" => "/poezda/index.php",
  )
);

in CONDITION I tried to specify various variations, such as #^/poezda#, #^/poezda, /poezdaetc.
Please tell me how to get rid of these slashes at the end?
PS The .htaccess file is standard, contains these lines for routing:
<IfModule mod_rewrite.c>
  Options +FollowSymLinks
  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]
  RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Dmitry Korolev, 2017-01-12
@iNickolay

I will assume that you add slashes at the server level, and not at the level of the site itself. And changes in urlrewrite do not affect the addition of slashes in any way, since this file is designed to parse url and include the necessary file for processing. And a question just in case: maybe some module for Bitrix is ​​installed, which adds slashes?
Are there any rules for redirecting pages without a slash to pages with a slash in .htaccess somewhere above the specified block?
You can also use the Yandex service https://webmaster.yandex.ru/tools/server-response/ to check the status of pages like site.ru/poezda/poezd2
I checked it on one of my sites, it worked for me as it should with the following changes to htaccess take.ms/N3WEE:
1. Add the DirectorySlash Off line to the mod_dir section
2. Add the lines
RewriteCond %{REQUEST_URI} ^.*[^/]$
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI}/index.php -f
RewriteRule ^(.*) to the mod_rewrite section $ /$1/index.php [L] Section
index pages now open with or without a slash at the end.

M
Maxim Timofeev, 2017-01-12
@webinar

https://yandex.ru/search/?text=htaccess%20remove%2...

T
ThunderCat, 2017-01-12
@ThunderCat

Here's a solution , learn to torment Google.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question