apachehttp-redirecthttpd.conf

Remove trailing slash redirect loop


I am using the following to remove the trailing slash:

 <VirtualHost *:80>


RewriteEngine On
RewriteRule ^(.*)/$ $1 [R=301,L]


</VirtualHost>

However, whenever I access my homepage (e.g. http://www.example.com/) I get a redirect loop


Solution

  •  <VirtualHost *:80>
    
    
    RewriteEngine On
    RewriteRule ^(.+)/$ $1 [R=301,L]
    
    
    </VirtualHost>
    

    Use + instead of *