Friday , December 20 2024

301 redirect without slash to slash

In this article, I posted examples for redirecting from the pages without a slash to pages with a slash.

Example 1: 301 redirect without slash to slash

RewriteCond %{REQUEST_URI} !\?
RewriteCond %{REQUEST_URI} !\&
RewriteCond %{REQUEST_URI} !\=
RewriteCond %{REQUEST_URI} !\.
RewriteCond %{REQUEST_URI} !\/$
RewriteRule ^(.*[^\/])$ /$1/ [R=301,L]

Example 2: 301 redirect without slash to slash

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*[^/])$ $1/ [L,R=301]

About admin

Hi there! My name is Iryna, I am a web developer from Ukraine. While working on freelance projects I often face different technical issues and in this blog I publish articles on how to solve them. I am also interested in digital drawing and in this blog you will find brief tutorials that helped me and hopefully can help you as well.

Check Also

How to find changed files in console

Relevant for Linux, macOS. This article lists commands that help you find files that have …

Leave a Reply

Your email address will not be published. Required fields are marked *