This forum has been moved here:
Helicon Tech Community Forum

  Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 3.0
 Helicon Tech : ISAPI_Rewrite 3.0
Subject Topic: Make URL lowercase and add trailing slash Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
kbw612
Newbie
Newbie


Joined: 26 January 2012
Online Status: Offline
Posts: 3
Posted: 26 January 2012 at 10:05pm | IP Logged Quote kbw612

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 View kbw612's Profile Search for other posts by kbw612
 
Guests
Guest
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -149
Posted: 27 January 2012 at 5:06am | IP Logged Quote Guests

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 View Guests's Profile Search for other posts by Guests
 
kbw612
Newbie
Newbie


Joined: 26 January 2012
Online Status: Offline
Posts: 3
Posted: 27 January 2012 at 6:45am | IP Logged Quote kbw612

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 View kbw612's Profile Search for other posts by kbw612
 
Guests
Guest
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -149
Posted: 31 January 2012 at 3:44am | IP Logged Quote Guests

Hello,

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

Regards
Andrew
Back to Top View Guests's Profile Search for other posts by Guests
 
kbw612
Newbie
Newbie


Joined: 26 January 2012
Online Status: Offline
Posts: 3
Posted: 31 January 2012 at 8:04am | IP Logged Quote kbw612

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 View kbw612's Profile Search for other posts by kbw612
 
Guests
Guest
Guest


Joined: 01 October 2003
Online Status: Online
Posts: -149
Posted: 03 February 2012 at 7:33am | IP Logged Quote Guests

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 View Guests's Profile Search for other posts by Guests
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You can vote in polls in this forum