2017-10-16 5 views
0

ページのURLが正常に動作しません。共通のヘッダーのhtml(header.html)を作成しました。私は&が&リンクを知ってSEEヘッダーのSENDを置くとき、私はそれにindex.htmlをでページのURLが正しく機能しない

{% load static%} 
<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet"> 
<link rel="stylesheet" href="{% static 'header.css' %}"> 
<header class="clearfix"> 
     <h1 class="title">WEB SITE</h1> 
     <ul class="top-menu"> 
      <li class="top-menu-item"><a class="icon_head" href="send">SEND</a></li> 
      <li class="top-menu-item"><a class="icon_head" href="see">SEE</a></li> 
      <li class="top-menu-item"><a class="icon_head" href="know">KNOW</a></li> 
      </ul> 
     <a class="logout_button" href="logout_view">LOGOUT</a> 
</header> 

を書いた は、header.htmlが

<html lang="ja"> 

<head> 
    <meta charset="UTF-8"> 
    <link href="/static/css/bootstrap.min.css" rel="stylesheet"> 
    <link rel="stylesheet" href="/static/accounts/detail.css"> 
    <link rel="stylesheet" href="/static/bootflat/css/bootflat.min.css"> 
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> 
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> 
    <script src="https://code.jquery.com/jquery-1.11.0.min.js"></script> 

    <title>WEB SITE</title> 
</head> 

<body class="relative"> 

<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet"> 
<link rel="stylesheet" href="/static/accounts/header.css"> 
{% load static%} 
    <link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet"> 
    <link rel="stylesheet" href="{% static 'header.css' %}"> 
    <header class="clearfix"> 
      <h1 class="title">WEB SITE</h1> 
         <ul class="top-menu"> 
       <li class="top-menu-item"><a class="icon_head" href="send">SEND</a></li> 
       <li class="top-menu-item"><a class="icon_head" href="see">SEE</a></li> 
       <li class="top-menu-item"><a class="icon_head" href="know">KNOW</a></li> 
       </ul> 
      <a class="logout_button" href="logout_view">LOGOUT</a> 
    </header> 

    <main> 
     <div class="container"> 
      <p>Hello World</p> 
     </div> 
    </main> 

    <footer> 
     <div class="footers"> 
     <ul class="bottom-menu"> 
       <li class="bottom-menu-item"><a class="bottom_index" href="">XOXO</a></li> 
     </ul> 
     </div> 
    </footer> 
</body> 

</html> 

のように読み込まれ、彼らが適切に働いていました。 一方、私は

<html lang="ja"> 
<head> 
    <meta charset="UTF-8"> 
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"> 
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootflat/2.0.4/css/bootflat.min.css"> 
    <link href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css" rel="stylesheet"> 
    <script src="https://code.jquery.com/jquery-1.11.0.min.js"></script> 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> 
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootflat/2.0.4/js/jquery.fs.selecter.min.js"></script> 
    <script src="https://cdnjs.cloudflare.com/ajax/libs/bootflat/2.0.4/js/jquery.fs.stepper.min.js"></script> 
<title>WEB SITE</title> 
<body class="relative"> 
<header class="clearfix"> 
    <h1 class="title">WEB SITE</h1> 
    <ul class="top-menu"> 
     <li class="top-menu-item"><i class="fa fa-plus" aria-hidden="true"><a class="icon_head" href="send">SEND</a></i> 
     </li> 
     <li class="top-menu-item"><i class="fa fa-eye" aria-hidden="true"><a class="icon_head" href="see">SEE</a></i> 
     </li> 
     <li class="top-menu-item"><i class="fa fa-search" aria-hidden="true"><a class="icon_head" 
                       href="know">KNOW</a></i></li> 
    </ul> 
    <a class="logout_button" href="logout_view">LOGOUT</a> 
</header> 

<main> 
    <div class="container"> 
     <div class="detailimg col-xs-8"> 
      <div class="relative_ele"> 
       <div class="image"> 
        <img class="absolute-fill" src="https://placehold.jp/3d4070/ffffff/150x150.png?text=results.jpg" 
         width="500px" height="300px" alt="SEE"> 
       </div> 
       <div class="vertical-center-container "> 
        <p class="hthree">I LOVE YOU</p> 
        <p class="hthree_small">I MISS YOU</p> 
       </div> 
      </div> 
      <div class="table-padding"> 
       <table border="0 " class="table table-bordered "> 
        <thead> 
        <tr> 
         <th class="index " colspan="4 " bgcolor=pink>ITEMS</th> 
        </tr> 
        </thead> 
        <tbody> 
        <tr> 
         <td bgcolor="#FFEEFF " rowspan="2" align="center ">XOXO1</td> 
         <td align="center "> 
          <a class="index" href="results1">XOXO2</a> 
         </td> 

         <td bgcolor="#FFEEFF " rowspan="4" align="center ">XOXO3</td> 
         <td align="center "> 
          <a class="index" href="results2">XOXO4</a> 
         </td> 
        </tr> 

        </tbody> 
       </table> 
      </div> 
    </div> 
</main> 
<footer> 
     <div class="footers"> 
     <ul class="bottom-menu"> 
       <li class="bottom-menu-item"><a class="bottom_index" href="">XOXO</a></li> 
     </ul> 
     </div> 
</footer> 

</body> 

</html> 

ようdetail.htmlに書いたが、私は、ヘッダのSEND &を入れたときに&、リンクを知ってSEE、彼らは動作しませんでしたとエラーhappens.For例、index.htmlの中でそれをリンクを送信http://localhost:8000/accounts/sendを送信しても問題ありません。 しかし、detail.htmlのSENDリンクはhttp://localhost:8000/accounts/detail/sendを送信します。 http://localhost:8000/accounts/detai lはdetail.htmlのURLです。 なぜこれが起こるのか分かりません。header.htmlをindex.html & detail.htmlに使用できません。これはどのように修正する必要がありますか?

答えて

0

<a href="send">Send</a>href属性「送信」は相対 URLです:ブラウザは、現在のページのURLにそれを追加することによってそれを解決します。

これは通常、必要な動作ではありません。解決策は、サイトのルートからの絶対パスを提供することです。

<a href="/send">Send</a>

とブラウザが常に正しくURLを解決します:だから「送信」ページの場合場所は次のように、URLをリード/を構築、その後http://localhost:8000/accounts/sendです。

this questionの回答も参照してください。

関連する問題