mod rewrite - remove multiple trailing slashes mod_rewrite -


I know this question was asked many times on this site alone, but browsing through relevant posts I could not find a trick. Trying to remove multiple trailing slashes after the domain. The following mod_rewrite expressions work like URLs, but do not work for the domain //

  DirectorySlash Off RewriteEngine # Canonical Fix Reiter Conduit% {HTTP_HOST}! ^ Www.domain.com $ [nc] rarolitules ^ (. *) $ Http://www.domain.com/$1 [R = 301] revised rules ^ / Main.do http://www.domain.com/ [R = 301, L] Right Raul ^ / Index.jsp http://www.domain.com/ [R = 301, L] Remove the bogus query string Rewind Conduit% {query_string} q = [nc] rewritable (. *) Http: //www.domain com / $ 1? [R = 301, L] Remove multiple slashes after #define - does not work !!! #RewriteCond% {REQUEST_URI} ^ // + (. *) $ [OR] #RewriteCond% {REQUEST_URI} ^ (. * /) / + $ #RewriteRule / http://www.domain.com/%1 [R = 301, L] Remove multiple slashes anywhere in the #RevortContact% {REQUEST_URI} ^ (. *) // (. *) $ RewriteRule% 1 /% 2 [R = 301, L] # Exclamation Slash External redirect to get rid of, advertise rewinded% {REQUEST_URI}! ^ / Ads / RewriteRule ^ (. +) / $ $ 1 [R = 301, L]  

can not be reproduced. Even after the domain, additional slash directories are never made with slabs closed - I have not checked whether it is opera or Apache, which is removing slash) but otherwise, everything works well:

  rewritebase / rewrite %% {REQUEST_URI} ^ // + (. *) $ [OR] rewrite% {REQUEST_URI} ^ (. * /) / + $ Redraft rule * http: // domain /% 1 [R = 301, L]  

Request

  127.0.0.1 - - [17 / May / 2010: 12: 26: 36 +0100] [Local host / sid # c08fb0] [Rid # 2756540 / initial] (3) [perdir c: / HTTP / htdocs /] Add Postfix Path Information: C: / HTTP / Htdocs / ABC - & gt; [Local Host / sid # c08fb0] [Raid # 2756540 / Initial] (3) [C: / HTTP / htdocs / abc / b / 127.0.0.1 - - [17 / May / 2010: 12: 26: 36 +0100] Perdir C: / HTTP / htdocs /] Per-Per-Direction Prefix: C: / HTTP / htdocs / abc / b / - & gt; [ABC / B / 127.0.0.1 - - [17 / May / 2010: 12: 26: 36 +0100] [Localhost / CID # C80FB] [Rid # 2756540 / Initial] (3) [perdir C : / HTTP / htdocs /] Pattern to Apply ' * 'Yuri' ABC / B / '127.0.0.1 - - [17 / May / 2010: 12: 26: 36 +0100] [Localhost / CID # C080FB 0] [Raid # 2756540 / Initial] (4 ) [Perdir c: / http / htdocs /] rewrite: input = '/ abc // b //' pattern = '^ // + (. *) $' = & Gt; 127.0.0.1 - [17 / May / 2010: 12: 26: 36 +0100] [Localhost / CID # C80 FB] [Rid # 2756540 / Initial] (4) [PEDAR C: / HTTP / HTTOCKS /] Rewrite: input = '/ ABC // b //' pattern = '^ (. * /) / + $' = & Gt; 127.0.0.1 - [17 / May / 2010: 12: 26: 36 +0100] [localhost / cid # cf80] [Rid # 2756540 / initial] (2) [perdir c: / http / htdocs /] Rewrite 'ABC / B /' - & gt; 'Http: // domain // abc //b /' 127.0.0.1 - - [17 / May / 2010: 12: 26: 36 +0100] [Local Host / sid # c08fb0] [Rid # 2756540 / Initial] ( 2) [Perdir C: / HTTP / htdocs /] Specifically http: // domain // abc // b / 127.0.0.1 - [17 / May / 2010: 12: 26: 36 +0100] [local host / Sid # c08fb0] [Rid # 2756540 / initial] (1) [perdir c: /http / htdocs /] http: // domain // redirect to abc //b / 127.0.0.1 - - [17 / May / [Local host / sid # c08fb0] [Rid # 2756540 / initial] (1) [perdir c: / http / htdocs /] http: // domain // abc // b / Note: Ignore hard-coding hosts:  
  Repeat Nkon% {HTTP_HOST}! = "" Rewrite %% {REQUEST_URI}  

^ // + (. *) $ [OR] rewrite condom% {REQUEST_URI} ^ (. * /) / + $ RewriteRule * Http: //% {HTTP_HOST} /% 1 [R = 301, L]

Also keep in mind that the internal "//" was not replaced. You must add another rule to replace the internal slash.

NEW Edit: OK, it works to prevent and stop the URL:

  RewriteEngine on RewriteBase / RewriteCond% {HTTP_HOST}! = "" Rewrite angle% {THE_REQUEST} ^ [AZ] + \ s // + (. *) \ SHTTP / [0-9.] + $ [OR] rewrite% {THE_REQUEST} ^ [AZ] + \ s (. * /) / + \ SHTTP / [0-9.] + $ RewriteRule. * Http: //% {HTTP_HOST} /% 1 [R = 301, L]  

Comments