N
N
Nickname123122016-09-02 17:00:40
URL Handling
Nickname12312, 2016-09-02 17:00:40

How to remove / from the end of a link?

Hello!
How to make a redirect when going from site.com/news/ to site.com/news?
Live example: formulaz.ru/mrt-skani needs to be redirected to formulaz.ru/mrt-skani /../../news to site.com/news. example - formulaz.ru/sometext/mrt-skani - the page is displayed but I would also like to redirect to formulaz.ru/mrt-skani

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} (.*)
RewriteCond %{REQUEST_URI} /$ [NC]
RewriteRule ^(.*)(/)$ $1 [L,R=301]

This option does not work, because the Apache file already has this code:
#php_value magic_quotes_gpc Off
Options +Includes +FollowSymLinks -Indexes



<IfModule mod_rewrite.c>

RewriteEngine On

RewriteRule ^index.html$ / [R=301,L]


RewriteRule ^search/$ index.php?module=search&mode=text&page=1 [L,QSA]
RewriteRule ^search/([0-9]+)/$ index.php?module=search&mode=text&page=$1 [L,QSA]


RewriteRule ^news$ index.php?module=news&page=news [L,QSA]
RewriteRule ^news/(.*)$ index.php?module=news&post=$1&page=news [L,QSA]

RewriteRule ^reviews$ index.php?module=ot&page=ot [L,QSA]
RewriteRule ^reviews/(.*)$ index.php?module=ot&post=$1&page=ot [L,QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} ^(.*)$
RewriteRule ^(.*) index.php?module=static_content&page=$1 [L,QSA]


</IfModule>

I need it urgently, I will be very grateful if someone from the knowledgeable can help!
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
A person from Kazakhstan, 2016-09-02
@LenovoId

what is the difference between this site.com/news/ and this site.com/news slash ?
This command is run in htaccess and it removes the slash from the URL :

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} (.*)
RewriteCond %{REQUEST_URI} /$ [NC]
RewriteRule ^(.*)(/)$ $1 [L,R=301]

here is the command to add a slash to the url :
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*[^/])$ $1/ [L,R=301]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question