Forum Moderators: phranque
ServerName images.example.com
ServerAlias *.int.example.com
DocumentRoot /var/repo/content/images.example.com
\"%{User-Agent}i\" \"ST=%D;IP=%{X-Forwarded-For}i\" img-sbc" comb
LogFormat "%t %V %h %U %q %m \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %T" comb
CustomLog "¦/usr/local/httpd/bin/rotatelogs /var/log/httpd/images.example.com/access-http.log.%Y%m%d 86400 -420" comb
ErrorLog "¦/usr/local/httpd/bin/rotatelogs /var/log/httpd/images.example.com/error-http.log.%Y%m%d 86400 -420"
LogLevel warn
RewriteEngine On
RewriteLogLevel 3
RewriteLog /var/log/httpd/images.example.com/rewrite.log
RewriteMap lowercase int:tolower
RewriteRule .* http://%{HTTP_HOST}${lowercase:%{REQUEST_URI}} [R,L]
</VirtualHost>
Whats happening is when I try to access url using alias
http://images.halimapa1.int.example.com/teST.gif
It converts the URL to
http://images.halimapa1.int.example.com/test.gif
This is what I expect,
But when I try this,
http://images.example.com/TEST.GIF
The server goes in loop, here are some logs from rewrite.log file,
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (1) escaping http://images.example.com/test.gif for redirect
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (1) redirect to http://images.example.com/test.gif [REDIRECT/302]
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (2) init rewrite engine with requested uri /test.gif
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (3) applying pattern '.*' to uri '/test.gif'
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (2) rewrite '/test.gif' -> 'http://images.example.com/test.gif'
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (2) explicitly forcing redirect with http://images.example.com/test.gif
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (1) escaping http://images.example.com/test.gif for redirect
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (1) redirect to http://images.example.com/test.gif [REDIRECT/302]
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (2) init rewrite engine with requested uri /test.gif
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (3) applying pattern '.*' to uri '/test.gif'
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (2) rewrite '/test.gif' -> 'http://images.example.com/test.gif'
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (2) explicitly forcing redirect with http://images.example.com/test.gif
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (1) escaping http://images.example.com/test.gif for redirect
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (1) redirect to http://images.example.com/test.gif [REDIRECT/302]
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (2) init rewrite engine with requested uri /test.gif
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (3) applying pattern '.*' to uri '/test.gif'
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (2) rewrite '/test.gif' -> 'http://images.example.com/test.gif'
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (2) explicitly forcing redirect with http://images.example.com/test.gif
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (1) escaping http://images.example.com/test.gif for redirect
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (1) redirect to http://images.example.com/test.gif [REDIRECT/302]
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (2) init rewrite engine with requested uri /test.gif
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (3) applying pattern '.*' to uri '/test.gif'
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (2) rewrite '/test.gif' -> 'http://images.example.com/test.gif'
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (2) explicitly forcing redirect with http://images.example.com/test.gif
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (1) escaping http://images.example.com/test.gif for redirect
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (1) redirect to http://images.example.com/test.gif [REDIRECT/302]
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (2) init rewrite engine with requested uri /test.gif
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (3) applying pattern '.*' to uri '/test.gif'
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (2) rewrite '/test.gif' -> 'http://images.example.com/test.gif'
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (2) explicitly forcing redirect with http://images.example.com/test.gif
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (1) escaping http://images.example.com/test.gif for redirect
10.0.0.148 - - [17/Jul/2008:17:54:33 --0700] [images.example.com/sid#1f8ce258][rid#1fc23ea8/initial] (1) redirect to http://images.example.com/test.gif [REDIRECT/302]
It converts the url to lowercase and then goes in loop. Dont know why
Any help would be appreciated.
Thank you,
-Jai
[edited by: jdMorgan at 1:05 am (utc) on July 18, 2008]
[edit reason] Please use example.com. See Terms of Service. [/edit]
Change your rule to
RewriteRule [b][A-Z][/b] http://%{HTTP_HOST}${lowercase:%{REQUEST_URI}} [R[b]=301[/b],L]
This rule will execute and redirect only if there are one or more uppercase letters in the requested URL-path.
Note also that you should specify [R=301,L] on your redirection rules, unless you want big trouble with the search engines. Use 302 redirects very carefully, and only when you fully understand the difference in the 301/302 response handling of all of the search engines that are important to your site.
In the case of a 302, search engines will fetch the new URL, but keep the old URL in their index, and this is most definitely not what you want here.
Jim