2013-11-03 357 views
0

我使用Espresso并收到此错误 - 加载资源失败:服务器响应的状态为404(未找到) 。这些图像位于名为images的文件夹内的espresso项目文件下。每当我将这段代码链接到我的网站上时,图片都不会显示,但是它们会显示在espresso的实时预览中。这是我的代码。无法加载资源:服务器响应的状态为404(未找到)

<!DOCTYPE html> 
<html lang="en"> 
    <head> 
    <meta charset="utf-8" /> 
    <title>ListApp</title> 
     <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile- 1.3.2.min.css"   /> 
    <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> 
    <script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"></script> 
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" /> 
    <style> 
     img.fullscreen { 
      max-height: 100%; 
      max-width: 100%; 
     } 
    </style> 
    </head> 
    <body> 
    <div data-role="page" id="photos"> 
    <header data-role="header"> 
     <h1> List App </h1> 
    </header> 
    <article data-role="content"> 
     <ul data-role"listview" data-filter="true"> 
      <li> 
       <a href="#dog"> 
       <h1>American Pitbull</h1> 
       <img src="images/IMG_1870.jpg" 
        alt="Pitbull" /> 
       <p>This is my sweet, loving Pitbull Kalvin. He's 3 years old and 
       a huge baby. He also likes to go out in style!</p> 
       </a> 
      </li> 
      <li> 
       <a href="#strobe"> 
       <h1>My Old Apartment's Lighting</h1> 
       <img src="images/IMG_1185.jpg" 
        alt="Strobe Light" /> 
       <p>We wanted to be able to light up the room in with different 
        colors and I found this on amazon and it's amazing. Friend's love 
       it and definately improves the mood.</p> 
       </a> 
      </li> 
     <ul> 
    </article> 
    <footer data-role="footer" data-position="fixed"> 
     <nav data-role="navbar"> 
      <ul> 
       <li><a href="#" data-icon"home">Home</a></li> 
       <li><a href="#" data-icon"grid">Photos</a></li> 
       <li><a href="#" data-icon"info">Info</a></li> 
      </ul> 
     </nav> 
    </footer> 
    </div><!-- page --> 

    <div data-role="page" id="dog"> 
    <header data-role="header"> 
     <h1> Dog </h1> 
     <a href="#photos" data-icon="grid" data-iconpos="notext">Photos</a> 
    </header> 
    <img src="images/IMG_1870.jpg" class="fullscreen" alt="Dog Picture" /> 
    </div><!-- page --> 

    <div data-role="page" id="strobe"> 
    <header data-role="header"> 
     <h1> Strobe Light </h1> 
     <a href="#photos" data-icon="grid" data-iconpos="notext">Photos</a> 
    </header> 
    <img src="images/IMG_1185.jpg" class="fullscreen" alt="Strobe Lights" /> 
    </div><!-- page --> 
    </body> 
</html> 

这里是我的.htaccess文件:

# BEGIN WPSuperCache 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
#If you serve pages from behind a proxy you may want to change 'RewriteCond %{HTTPS} on' to something more sensible 
AddDefaultCharset UTF-8 
RewriteCond %{REQUEST_URI} !^.*[^/]$ 
RewriteCond %{REQUEST_URI} !^.*//.*$ 
RewriteCond %{REQUEST_METHOD} !POST 
RewriteCond %{QUERY_STRING} !.*=.* 
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$ 
RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC] 
RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC] 
RewriteCond %{HTTP:Accept-Encoding} gzip 
RewriteCond %{HTTPS} on 
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{SERVER_NAME}/$1/index-https.html.gz -f 
RewriteRule ^(.*) "/wp-content/cache/supercache/%{SERVER_NAME}/$1/index-https.html.gz" [L] 

RewriteCond %{REQUEST_URI} !^.*[^/]$ 
RewriteCond %{REQUEST_URI} !^.*//.*$ 
RewriteCond %{REQUEST_METHOD} !POST 
RewriteCond %{QUERY_STRING} !.*=.* 
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$ 
RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC] 
RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC] 
RewriteCond %{HTTP:Accept-Encoding} gzip 
RewriteCond %{HTTPS} !on 
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{SERVER_NAME}/$1/index.html.gz -f 
RewriteRule ^(.*) "/wp-content/cache/supercache/%{SERVER_NAME}/$1/index.html.gz" [L] 

RewriteCond %{REQUEST_URI} !^.*[^/]$ 
RewriteCond %{REQUEST_URI} !^.*//.*$ 
RewriteCond %{REQUEST_METHOD} !POST 
RewriteCond %{QUERY_STRING} !.*=.* 
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$ 
RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC] 
RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC] 
RewriteCond %{HTTPS} on 
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{SERVER_NAME}/$1/index-https.html -f 
RewriteRule ^(.*) "/wp-content/cache/supercache/%{SERVER_NAME}/$1/index-https.html" [L] 

RewriteCond %{REQUEST_URI} !^.*[^/]$ 
RewriteCond %{REQUEST_URI} !^.*//.*$ 
RewriteCond %{REQUEST_METHOD} !POST 
RewriteCond %{QUERY_STRING} !.*=.* 
RewriteCond %{HTTP:Cookie} !^.*(comment_author_|wordpress_logged_in|wp-postpass_).*$ 
RewriteCond %{HTTP:X-Wap-Profile} !^[a-z0-9\"]+ [NC] 
RewriteCond %{HTTP:Profile} !^[a-z0-9\"]+ [NC] 
RewriteCond %{HTTPS} !on 
RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{SERVER_NAME}/$1/index.html -f 
RewriteRule ^(.*) "/wp-content/cache/supercache/%{SERVER_NAME}/$1/index.html" [L] 
</IfModule> 

# END WPSuperCache 

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 

# END WordPress 

回答

1

的问题是在对图像的相对路径。

src="images/IMG_1185.jpg" < - 相对于当前目录

例如当你在网站的地址为“http://domain.com/contact”,它将在/contact/images

搜索图像要解决这个问题,您需要更改图像路径到绝对的,添加到http://domain.com/图像源,像

src="http://domain.com/images/IMG_1185.jpg" < - 绝对路径

在图像源的开头

或添加/,像这样:

src="/images/IMG_1185.jpg" < - 相对于基本目录

我建议使用第一种方法,因为它是更安全的。

+0

这两种方法都没有效果。 –

+0

那么在实时预览中图像的真实地址是什么?也许重写规则会将请求重定向到其他地方。 –

+0

/Users/admin /图片是图片的真实地址 –

相关问题