我有规则(下面),我们添加了一个新的别名/ msn,它有一些静态内容,比如html文件ayuda.html
,它是目录索引文件和一些图像。
目前我可以看到HTML文件,但不能看到图像。如果我转到domain.com/msn
或domain.com/msn/
,也会有不同的错误。在第一种情况下,图像位置不会被重写为domain.com/msn/image-blah-blah.jpg
,但它会在第二种情况下重写。
这是虚拟目录:
<VirtualHost *:80>
ServerAdmin administracion.linux@yellargentina.com
DocumentRoot "/opt/tomcat-5.5.30/webapps/portalPA"
ServerAlias *.amarillas.tm.yellargentina.com
CustomLog /tmp/amarillas-access_log combined
ErrorLog /tmp/amarillas-error_log
RewriteLog /tmp/amarillas-rewrite_log
RewriteLogLevel 9
JkUnMount /images/*.gif w1
JkUnMount /images/*.png w1
JkUnMount /images/*.jpg w1
JkUnMount /js/*.js w1
JkUnMount /styles/*.css w1
#JkMount /jkmanager/* jkstatus
JkMount /portalPA w1
JkMount /portalPA/* w1
JkUnMount /msn/* w1
CookieName PaginasAmarillas
CookieExpires "2 years"
CookieDomain ".tm.yellargentina.com"
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
Options +FollowSymlinks
RewriteRule ^/(msn|msn/) /msn/ayuda.html [PT]
RewriteRule ^/msn/ayuda.html$ /msn/ [R,L]
RewriteRule ^/msn/(?!ayuda.html)(.*) /msn/$1 [R,L]
RewriteRule ^/$ /portalPA/index.action [PT]
RewriteRule ^/portalPA/index.action / [R]
RewriteRule ^/(?!portalPA/)(.*) /portalPA/$1 [PT]
</VirtualHost>
当我尝试访问domain.com/msn/
10.248.19.52 - - [23/Aug/2011:16:54:36 --0300] [amarillas.tm.yellargentina.com/sid#2af084b03cd0][rid#2af084bc8338/initial] (2) init rewrite engine with requested uri /msn/yello-apps-mesenger.jpg
10.248.19.52 - - [23/Aug/2011:16:54:36 --0300] [amarillas.tm.yellargentina.com/sid#2af084b03cd0][rid#2af084bc8338/initial] (3) applying pattern '.*' to uri '/msn/yello-apps-mesenger.jpg'
10.248.19.52 - - [23/Aug/2011:16:54:36 --0300] [amarillas.tm.yellargentina.com/sid#2af084b03cd0][rid#2af084bc8338/initial] (4) RewriteCond: input='GET' pattern='^(TRACE|TRACK)' => not-matched
10.248.19.52 - - [23/Aug/2011:16:54:36 --0300] [amarillas.tm.yellargentina.com/sid#2af084b03cd0][rid#2af084bc8338/initial] (3) applying pattern '^/(msn|msn/)' to uri '/msn/yello-apps-mesenger.jpg'
10.248.19.52 - - [23/Aug/2011:16:54:36 --0300] [amarillas.tm.yellargentina.com/sid#2af084b03cd0][rid#2af084bc8338/initial] (2) rewrite '/msn/yello-apps-mesenger.jpg' -> '/msn/ayuda.html'
10.248.19.52 - - [23/Aug/2011:16:54:36 --0300] [amarillas.tm.yellargentina.com/sid#2af084b03cd0][rid#2af084bc8338/initial] (2) forcing '/msn/ayuda.html' to get passed through to next API URI-to-filename handler
当我尝试访问domain.com/msn
10.248.19.52 - - [23/Aug/2011:16:55:33 --0300] [amarillas.tm.yellargentina.com/sid#2af084b03cd0][rid#2af084bc02f8/initial] (2) init rewrite engine with requested uri /msn
10.248.19.52 - - [23/Aug/2011:16:55:33 --0300] [amarillas.tm.yellargentina.com/sid#2af084b03cd0][rid#2af084bc02f8/initial] (3) applying pattern '.*' to uri '/msn'
10.248.19.52 - - [23/Aug/2011:16:55:33 --0300] [amarillas.tm.yellargentina.com/sid#2af084b03cd0][rid#2af084bc02f8/initial] (4) RewriteCond: input='GET' pattern='^(TRACE|TRACK)' => not-matched
10.248.19.52 - - [23/Aug/2011:16:55:33 --0300] [amarillas.tm.yellargentina.com/sid#2af084b03cd0][rid#2af084bc02f8/initial] (3) applying pattern '^/(msn|msn/)' to uri '/msn'
10.248.19.52 - - [23/Aug/2011:16:55:33 --0300] [amarillas.tm.yellargentina.com/sid#2af084b03cd0][rid#2af084bc02f8/initial] (2) rewrite '/msn' -> '/msn/ayuda.html'
10.248.19.52 - - [23/Aug/2011:16:55:33 --0300] [amarillas.tm.yellargentina.com/sid#2af084b03cd0][rid#2af084bc02f8/initial] (2) forcing '/msn/ayuda.html' to get passed through to next API URI-to-filename handler
10.248.19.52 - - [23/Aug/2011:16:55:33 --0300] [amarillas.tm.yellargentina.com/sid#2af084b03cd0][rid#2af084bb82b8/initial] (2) init rewrite engine with requested uri /yello-apps-mesenger.jpg
10.248.19.52 - - [23/Aug/2011:16:55:33 --0300] [amarillas.tm.yellargentina.com/sid#2af084b03cd0][rid#2af084bb82b8/initial] (3) applying pattern '.*' to uri '/yello-apps-mesenger.jpg'
10.248.19.52 - - [23/Aug/2011:16:55:33 --0300] [amarillas.tm.yellargentina.com/sid#2af084b03cd0][rid#2af084bb82b8/initial] (4) RewriteCond: input='GET' pattern='^(TRACE|TRACK)' => not-matched
10.248.19.52 - - [23/Aug/2011:16:55:33 --0300] [amarillas.tm.yellargentina.com/sid#2af084b03cd0][rid#2af084bb82b8/initial] (3) applying pattern '^/(msn|msn/)' to uri '/yello-apps-mesenger.jpg'
10.248.19.52 - - [23/Aug/2011:16:55:33 --0300] [amarillas.tm.yellargentina.com/sid#2af084b03cd0][rid#2af084bb82b8/initial] (3) applying pattern '^/msn/ayuda.html$' to uri '/yello-apps-mesenger.jpg'
10.248.19.52 - - [23/Aug/2011:16:55:33 --0300] [amarillas.tm.yellargentina.com/sid#2af084b03cd0][rid#2af084bb82b8/initial] (3) applying pattern '^/msn/(?!ayuda.html)(.*)' to uri '/yello-apps-mesenger.jpg'
10.248.19.52 - - [23/Aug/2011:16:55:33 --0300] [amarillas.tm.yellargentina.com/sid#2af084b03cd0][rid#2af084bb82b8/initial] (3) applying pattern '^/$' to uri '/yello-apps-mesenger.jpg'
10.248.19.52 - - [23/Aug/2011:16:55:33 --0300] [amarillas.tm.yellargentina.com/sid#2af084b03cd0][rid#2af084bb82b8/initial] (3) applying pattern '^/portalPA/index.action' to uri '/yello-apps-mesenger.jpg'
10.248.19.52 - - [23/Aug/2011:16:55:33 --0300] [amarillas.tm.yellargentina.com/sid#2af084b03cd0][rid#2af084bb82b8/initial] (3) applying pattern '^/(?!portalPA/)(.*)' to uri '/yello-apps-mesenger.jpg'
10.248.19.52 - - [23/Aug/2011:16:55:33 --0300] [amarillas.tm.yellargentina.com/sid#2af084b03cd0][rid#2af084bb82b8/initial] (2) rewrite '/yello-apps-mesenger.jpg' -> '/portalPA/yello-apps-mesenger.jpg'
10.248.19.52 - - [23/Aug/2011:16:55:33 --0300] [amarillas.tm.yellargentina.com/sid#2af084b03cd0][rid#2af084bb82b8/initial] (2) forcing '/portalPA/yello-apps-mesenger.jpg' to get passed through to next API URI-to-filename handler
答案 0 :(得分:0)
根据提供的重写日志,我得出结论yello-apps-mesenger.jpg
是有问题的图像。据我所知,上述图片是从/msn
页面链接的。
我认为这完全取决于您如何编写<img>
标记(或者您使用该图像的位置)。我猜它是相对于当前文档声明的:<img src="yello-apps-mesenger.jpg" />
。
嗯 - 这就是问题所在:
domain.com/msn/
时,将要求domain.com/msn/yello-apps-mesenger.jpg
domain.com/msn
(没有尾随斜杠)时,系统会像domain.com/yello-apps-mesenger.jpg
和^/(msn|msn/)
那样请求图像,而不是应用它。TBH我不知道哪一个出错 - 你不清楚这一点(至少我无法弄明白ATM)。
我看到了两种解决问题的方法:
1。只接受domain.com/msn/
而不是domain.com/msn
(或其他方式),并在此基础上制定规则。
2. 修复图片网址 - 然后相对于网站根目录,例如:<img src="/yello-apps-mesenger.jpg" />
(注意前导斜杠)..或者<img src="/msn/yello-apps-mesenger.jpg" />
({ {1}}是图片网址的一部分 - 您应该更清楚地知道什么对您有好处。