Redirect all urls ending in “/”

I need to redirect all URLs ending in "/" to urls that don't end in "/".

Example:            ->      ->  ->          ->

I've tried the following approaches, but none work:

  • RewriteRule ^(.*)\/+$ http:\/\/www\.%{HTTP_HOST}/$1 [R=301,L]
  • RewriteRule (.*)\/+$ http:\/\/www\.%{HTTP_HOST}/$1 [R=301,L]


You can use this rule in root .htaccess:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?)/$ /$1 [NE,R=302,L]

RewriteCond %{THE_REQUEST} \s/{2,}[?\s]
RewriteRule ^$ / [R=302,L]

Need Your Help

Symfony dependency injection and your own services

php symfony2 dependency-injection

I am trying to register my own class as a services with help of symfony dependency injection component, but i have problems with class loading.

Python regex help

python regex

a = Account(unit = 2, path='/real/os/win/today/axl.xls', realname = 'st')

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.