This forum has been moved here:
Helicon Tech Community Forum

ISAPI_Rewrite 3.0 (Forum Locked Forum Locked)
 Helicon Tech : ISAPI_Rewrite 3.0
Subject Topic: Make URL lowercase and add trailing slash
Author
Message |
kbw612
Newbie


Joined: 26 January 2012
Posts: 3
Posted: 26 January 2012 at 10:05pm

How do I make all my URLs lowercase and include a trailing slash if missing in a single Rewrite statement?  I would like to handle this in a single permanent redirect as opposed to two permanent redirects.

Example :
Based on my current config file these requests happen for http://www.website.com/FOLDER:

a) browser sends request http://www.website.com/FOLDER
b) Rewrite sends http://www.website.com/folder redirect to browser
c) browser sends request http://www.website.com/folder
d) Rewrite sends http://www.website.com/folder/ redirect to browser
e) browser sends request http://www.website.com/folder/

# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.88

# all urls should be lowercase
# exclude certain folders
RewriteCond %{REQUEST_URI} ^(?!.*(?:images|css|js|lib|cm|global|workarea|admin|1|des|dl|notrk|xmlfiles))(.*)$ [NC]
# exclude certain extensions
RewriteCond %{REQUEST_URI} !\.(?:axd|asmx|ico) [NC]
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule .? %{REQUEST_URI}\?%{QUERY_STRING} [CL,R=301,L]

# fix missing trailing slash
# exclude certain folders
RewriteCond %{REQUEST_URI} ^(?!.*(?:images|css|js|lib|cm|global|workarea|admin|1|des|dl|notrk|xmlfiles))(.*)$ [NC]
RewriteRule ^([^.?]+[^.?/])$ $1/ [R=301]



Edited by kbw612 - 26 January 2012 at 10:07pm
Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 27 January 2012 at 5:06am

Hello,

Simply erase the [L]-flag from the first rule so that ISAPI_Rewrite will continue processing your request without sending it to browser.

Regards
Andrew
Back to Top
 
kbw612
Newbie


Joined: 26 January 2012
Posts: 3
Posted: 27 January 2012 at 6:45am

Thanks for the response. I removed the [L] but the trailing slash was not added.� I have included my updated config file and the Rewrite log:



# Helicon ISAPI_Rewrite configuration file# Version 3.1.0.88


# all urls should be lowercase# exclude certain folders
RewriteCond %{REQUEST_URI} ^(?!.*(?:images|css|js|lib|cm|global|workarea|admin|1|des|dl|notrk|xmlfiles))(.*)$ [NC]
# exclude certain extensions
RewriteCond %{REQUEST_URI} !\.(?:axd|asmx|ico) [NC]
RewriteCond %{REQUEST_URI} [A-Z]
RewriteRule .? %{REQUEST_URI}\?%{QUERY_STRING} [CL,R=301]
# fix missing trailing slash# exclude certain folders
RewriteCond %{REQUEST_URI} ^(?!.*(?:images|css|js|lib|cm|global|workarea|admin|1|des|dl|notrk|xmlfiles))(.*)$ [NC]
RewriteRule ^([^.?]+[^.?/])$ $1/ [R=301]

] (2) init rewrite engine with requested uri /FOLDER
] (1) Htaccess process request D:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
] (1) Htaccess process request d:\inetpub\business\dev\root\.htaccess
] (3) applying pattern '.?' to uri 'FOLDER'
] (4) RewriteCond: input='/FOLDER' pattern='^(?!.*(?:images|css|js|lib|cm|global|workarea|admin|1|des|dl|notrk|xmlfiles))(.*)$' => matched
] (4) RewriteCond: input='/FOLDER' pattern='\.(?:axd|asmx|ico)' => matched
] (4) RewriteCond: input='/FOLDER' pattern='[A-Z]' => matched
] (1) escaping /folder
] (2) explicitly forcing redirect with http://www-dev.michiganadvantage.org/folder
] (2) internal redirect with /FOLDER [INTERNAL REDIRECT]

Edited by AndrushkaUS - 30 January 2012 at 4:01am
Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 31 January 2012 at 3:44am

Hello,

How about moving the slash-rule on top of the lowercase-rule?

Regards
Andrew
Back to Top
 
kbw612
Newbie


Joined: 26 January 2012
Posts: 3
Posted: 31 January 2012 at 8:04am

Thanks for the response.
That didn't work as intended. Anything else to try
1) http://www-dev.michiganadvantage.org/folder-> permanent redirect. no trailing slash included. trailing
slash should be added.
2) http://www-dev.michiganadvantage.org/folder/ -> permanent direct to the same url (/folder/). No
redrect should happen. isapi filter should pass along request without redirect.

Config file:
Code:
# Helicon ISAPI_Rewrite configuration file# Version 3.1.0.88
# URLs should be lowercase and contain trailing slash
# exclude foldersRewriteCond %{REQUEST_URI} ^(?!.*(?:images/|css/|js/|lib/|cm/|global/|workarea/|admin/|des/|dl/|notrk/|xmlfiles/))(.*)$ [NC]
# exclude filesRewriteCond %{REQUEST_URI} ^(?!.*(?:PageNotFound\.aspx|Error\.aspx|al\.aspx|logout\.aspx|preview\.aspx))(.*)$ [NC]
# exclude extensionsRewriteCond %{REQUEST_URI} !\.(?:axd|asmx|ashx|ico|xml) [NC]
# contains uppercase character?RewriteCond %{REQUEST_URI}\?%{QUERY_STRING} [A-Z]
RewriteRule ^([^.?]+[^.?/])$ $1/\?%{QUERY_STRING} [CL,NE,C]RewriteRule .? %{REQUEST_URI}\?%{QUERY_STRING} [CL,NE,R=301]

Log file:
Code:
(2) init rewrite engine with requested uri /folder
(1) Htaccess process request D:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
(1) Htaccess process request d:\inetpub\business\dev\root\.htaccess
(3) applying pattern '^([^.?]+[^.?/])$' to uri 'folder'
(4) RewriteCond: input='/folder' pattern='^(?!.*(?:images/|css/|js/|lib/|cm/|global/|workarea/|admin/|des/|dl/|notrk/|xmlfiles/))(.*)$' => matched
(4) RewriteCond: input='/folder' pattern='^(?!.*(?:PageNotFound\.aspx|Error\.aspx|al\.aspx|logout\.aspx|preview\.aspx))(.*)$' => matched
(4) RewriteCond: input='/folder' pattern='\.(?:axd|asmx|ashx|ico|xml)' => matched
(4) RewriteCond: input='/folder?' pattern='[A-Z]' => not-matched
(3) applying pattern '.?' to uri 'folder'
(2) explicitly forcing redirect with http://www-dev.michiganadvantage.org/folder
(2) internal redirect with /folder [INTERNAL REDIRECT]

(2) init rewrite engine with requested uri /folder/
(1) Htaccess process request D:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
(1) Htaccess process request d:\inetpub\business\dev\root\.htaccess
(3) applying pattern '^([^.?]+[^.?/])$' to uri 'folder/'
(3) applying pattern '.?' to uri 'folder/'
(2) explicitly forcing redirect with http://www-dev.michiganadvantage.org/folder/
(2) internal redirect with /folder/ [INTERNAL REDIRECT]

(2) init rewrite engine with requested uri /folder/?1=TOP
(1) Htaccess process request D:\Program Files\Helicon\ISAPI_Rewrite3\httpd.conf
(1) Htaccess process request d:\inetpub\business\dev\root\.htaccess
(3) applying pattern '^([^.?]+[^.?/])$' to uri 'folder/'
(3) applying pattern '.?' to uri 'folder/'
(2) explicitly forcing redirect with http://www-dev.michiganadvantage.org/folder/?1=top
(2) internal redirect with /folder/?1=TOP [INTERNAL REDIRECT]


Edited by AndrushkaUS - 01 February 2012 at 4:50am
Back to Top
 
Guests
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -160
Posted: 03 February 2012 at 7:33am

What if we simply try to use:

RewriteCond %{REQUEST_URI} ^(?!.*(?:images|css|js|lib|cm|global|workarea|admin|1|des|dl|notrk|xmlfiles))(.*)$ [NC]
RewriteRule ^([^.?]+[^.?/])$ $1/ [CL,R=301,L]

Regards
Andrew

Back to Top
 

Sorry, you can NOT post a reply.
This forum has been locked by a forum administrator.

Printable version Printable version