0

I have the following code in my .htaccess file:


redirect 301 /file-a /folder1/file-a.html

RewriteCond %{REQUEST_URI} /+[^\.]+$ 
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [R=301,L]

RewriteRule ^(.+?\.html)/ /$1 [R=301,L]mediyaar

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME}\.php -f 
RewriteRule ^(.*)$ $1.php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1

The above code is giving me the desired results but too many redirects are there.

I am looking for below redirection of my pages, can this be achieved with a single redirect

  1. https://www.example.com/file-a
    ( redirect 301 to ) https://www.example.com/folder1/file-a.html

  2. https://www.example.com/folder1 ( Add Force Trailing Slash at the end for the folders ) https://www.example.com/folder1/

  3. https://www.example.com/folder1/file-a-b-c.html/ ( remove Trailing Slash at the end for the file ) https://www.example.com/folder1/file-a-b-c.html

Stephen Ostermiller
  • 23,933
  • 14
  • 88
  • 109
Medi Yaar
  • 11
  • 1

0 Answers0