<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ドキュメントルート | Seek Rise</title>
	<atom:link href="https://seek-rise.com/tag/%E3%83%89%E3%82%AD%E3%83%A5%E3%83%A1%E3%83%B3%E3%83%88%E3%83%AB%E3%83%BC%E3%83%88/feed/" rel="self" type="application/rss+xml" />
	<link>https://seek-rise.com</link>
	<description></description>
	<lastBuildDate>Tue, 17 Mar 2026 15:39:59 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://seek-rise.com/wp-content/uploads/2019/10/cropped-favicon-32x32.png</url>
	<title>ドキュメントルート | Seek Rise</title>
	<link>https://seek-rise.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<atom:link rel="hub" href="https://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="https://pubsubhubbub.superfeedr.com"/><atom:link rel="hub" href="https://websubhub.com/hub"/><site xmlns="com-wordpress:feed-additions:1">167377966</site>	<item>
		<title>2-5 ドキュメントルートとURLの関係を理解する｜「どこに置けば表示されるのか」</title>
		<link>https://seek-rise.com/web-development/setup/post-259/</link>
					<comments>https://seek-rise.com/web-development/setup/post-259/#respond</comments>
		
		<dc:creator><![CDATA[NOA（ノア）]]></dc:creator>
		<pubDate>Sun, 14 Dec 2025 17:49:20 +0000</pubDate>
				<category><![CDATA[Web開発学習ロードマップ]]></category>
		<category><![CDATA[2.開発環境構築]]></category>
		<category><![CDATA[MAMP]]></category>
		<category><![CDATA[ドキュメントルート]]></category>
		<category><![CDATA[URL]]></category>
		<category><![CDATA[localhost]]></category>
		<guid isPermaLink="false">https://seek-rise.com/?p=259</guid>

					<description><![CDATA[開発環境を構築して、PHPやHTMLが動くようになったあと、 多くの人が次の疑問にぶつかります。 ・ファイルをどこに置けばいいのか分からない・URLとフォルダの関係が分からない・なぜ表示されないのか分からない この原因は [&#8230;]]]></description>
										<content:encoded><![CDATA[<p data-start="230" data-end="263">開発環境を構築して、<br data-start="240" data-end="243" />PHPやHTMLが動くようになったあと、</p>
<p data-start="265" data-end="282">多くの人が次の疑問にぶつかります。</p>
<p data-start="284" data-end="347">・ファイルをどこに置けばいいのか分からない<br data-start="305" data-end="308" />・URLとフォルダの関係が分からない<br data-start="326" data-end="329" />・なぜ表示されないのか分からない</p>
<p data-start="349" data-end="386">この原因は、<br data-start="355" data-end="358" />👉 <strong data-start="361" data-end="379">ドキュメントルートの理解不足</strong> にあります。</p>
<p data-start="388" data-end="424">この記事では、<br data-start="395" data-end="398" /><strong data-start="398" data-end="419">URLとファイルの関係を完全に整理</strong> します。</p>
<hr data-start="426" data-end="429" />

  <div id="toc" class="toc tnt-number toc-center tnt-number border-element"><input type="checkbox" class="toc-checkbox" id="toc-checkbox-2" checked><label class="toc-title" for="toc-checkbox-2">目次</label>
    <div class="toc-content">
    <ol class="toc-list open"><li><a href="#toc1" tabindex="0">この記事で学べること</a></li><li><a href="#toc2" tabindex="0">ドキュメントルートとは何か</a></li><li><a href="#toc3" tabindex="0">イメージで理解する</a></li><li><a href="#toc4" tabindex="0">URLとの対応関係</a></li><li><a href="#toc5" tabindex="0">フォルダを使った場合</a></li><li><a href="#toc6" tabindex="0">indexファイルの特別な扱い</a></li><li><a href="#toc7" tabindex="0">よくある構成パターン</a></li><li><a href="#toc8" tabindex="0">なぜ表示されないのか</a></li><li><a href="#toc9" tabindex="0">よくあるミス①：場所が違う</a></li><li><a href="#toc10" tabindex="0">よくあるミス②：パスのズレ</a></li><li><a href="#toc11" tabindex="0">よくあるミス③：大文字小文字</a></li><li><a href="#toc12" tabindex="0">相対パスとの関係</a></li><li><a href="#toc13" tabindex="0">PHPとの関係</a></li><li><a href="#toc14" tabindex="0">実践：確認してみよう</a></li><li><a href="#toc15" tabindex="0">まとめ</a></li><li><a href="#toc16" tabindex="0">次に読むべき記事</a></li></ol>
    </div>
  </div>

<h2 data-section-id="189k5z7" data-start="431" data-end="444"><span id="toc1">この記事で学べること</span></h2>
<p data-start="446" data-end="518">・ドキュメントルートとは何か<br data-start="460" data-end="463" />・URLとファイルパスの対応関係<br data-start="479" data-end="482" />・フォルダ構造とURLの関係<br data-start="496" data-end="499" />・表示されないときの原因の見つけ方</p>
<hr data-start="520" data-end="523" />
<h2 data-section-id="1s4bw6w" data-start="525" data-end="541"><span id="toc2">ドキュメントルートとは何か</span></h2>
<p data-start="543" data-end="555">ドキュメントルートとは、</p>
<p data-start="557" data-end="585">👉 <strong data-start="560" data-end="585">ブラウザからアクセスできる「公開フォルダ」</strong></p>
<p data-start="587" data-end="593">のことです。</p>
<p data-start="595" data-end="602">簡単に言うと、</p>
<p data-start="604" data-end="631">👉 <strong data-start="607" data-end="631">ここに置いたファイルだけがURLで見える</strong></p>
<p data-start="633" data-end="641">という場所です。</p>
<hr data-start="643" data-end="646" />
<h2 data-section-id="1hikxp0" data-start="648" data-end="660"><span id="toc3">イメージで理解する</span></h2>
<p data-start="662" data-end="697">例えば、<br data-start="666" data-end="669" />MAMPやXAMPPでは、次のようなフォルダがあります。</p>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">
<pre class="cm-content q9tKkq_readonly">/htdocs/
index.php
test.html</pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="">
<div class="">この <code data-start="748" data-end="757">/htdocs</code> が</div>
</div>
</div>
</div>
</div>
<p data-start="745" data-end="779"><strong data-start="762" data-end="775">ドキュメントルート</strong> です。</p>
<hr data-start="781" data-end="784" />
<h2 data-section-id="mgas96" data-start="786" data-end="798"><span id="toc4">URLとの対応関係</span></h2>
<p data-start="800" data-end="823">このとき、<br data-start="805" data-end="808" />URLは次のように対応します。</p>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">

<a rel="noopener" href="http://localhost/index.php" title="&#28961;&#21177;&#12394;URL&#12391;&#12377;" class="blogcard-wrap external-blogcard-wrap a-wrap cf" target="_blank"><div class="blogcard external-blogcard eb-left cf"><div class="blogcard-label external-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail external-blogcard-thumbnail"><img decoding="async" src="https://s.wordpress.com/mshots/v1/http%3A%2F%2Flocalhost%2Findex.php?w=160&#038;h=90" alt="" class="blogcard-thumb-image external-blogcard-thumb-image" width="160" height="90" /></figure><div class="blogcard-content external-blogcard-content"><div class="blogcard-title external-blogcard-title">&#28961;&#21177;&#12394;URL&#12391;&#12377;</div><div class="blogcard-snippet external-blogcard-snippet"></div></div><div class="blogcard-footer external-blogcard-footer cf"><div class="blogcard-site external-blogcard-site"><div class="blogcard-favicon external-blogcard-favicon"><img decoding="async" src="https://www.google.com/s2/favicons?domain=http://localhost/index.php" alt="" class="blogcard-favicon-image external-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain external-blogcard-domain">localhost</div></div></div></div></a>
→ /htdocs/index.php


<a rel="noopener" href="http://localhost/test.html" title="&#28961;&#21177;&#12394;URL&#12391;&#12377;" class="blogcard-wrap external-blogcard-wrap a-wrap cf" target="_blank"><div class="blogcard external-blogcard eb-left cf"><div class="blogcard-label external-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail external-blogcard-thumbnail"><img decoding="async" src="https://s.wordpress.com/mshots/v1/http%3A%2F%2Flocalhost%2Ftest.html?w=160&#038;h=90" alt="" class="blogcard-thumb-image external-blogcard-thumb-image" width="160" height="90" /></figure><div class="blogcard-content external-blogcard-content"><div class="blogcard-title external-blogcard-title">&#28961;&#21177;&#12394;URL&#12391;&#12377;</div><div class="blogcard-snippet external-blogcard-snippet"></div></div><div class="blogcard-footer external-blogcard-footer cf"><div class="blogcard-site external-blogcard-site"><div class="blogcard-favicon external-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=http://localhost/test.html" alt="" class="blogcard-favicon-image external-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain external-blogcard-domain">localhost</div></div></div></div></a>
→ /htdocs/test.html</pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="">
<div class="">つまり、</div>
</div>
</div>
</div>
</div>
<p data-start="939" data-end="966">👉 <strong data-start="942" data-end="966">URLはドキュメントルートからの相対位置</strong></p>
<p data-start="968" data-end="976">を表しています。</p>
<hr data-start="978" data-end="981" />
<h2 data-section-id="czw22n" data-start="983" data-end="996"><span id="toc5">フォルダを使った場合</span></h2>
<p data-start="998" data-end="1025">フォルダを作ると、<br data-start="1007" data-end="1010" />URLもその構造に対応します。</p>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">
<pre class="cm-content q9tKkq_readonly">/htdocs/
sample/
index.html</pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="">
<div class="">この場合、</div>
</div>
</div>
</div>
</div>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">

<a rel="noopener" href="http://localhost/sample/index.html" title="&#28961;&#21177;&#12394;URL&#12391;&#12377;" class="blogcard-wrap external-blogcard-wrap a-wrap cf" target="_blank"><div class="blogcard external-blogcard eb-left cf"><div class="blogcard-label external-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail external-blogcard-thumbnail"><img loading="lazy" decoding="async" src="https://s.wordpress.com/mshots/v1/http%3A%2F%2Flocalhost%2Fsample%2Findex.html?w=160&#038;h=90" alt="" class="blogcard-thumb-image external-blogcard-thumb-image" width="160" height="90" /></figure><div class="blogcard-content external-blogcard-content"><div class="blogcard-title external-blogcard-title">&#28961;&#21177;&#12394;URL&#12391;&#12377;</div><div class="blogcard-snippet external-blogcard-snippet"></div></div><div class="blogcard-footer external-blogcard-footer cf"><div class="blogcard-site external-blogcard-site"><div class="blogcard-favicon external-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=http://localhost/sample/index.html" alt="" class="blogcard-favicon-image external-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain external-blogcard-domain">localhost</div></div></div></div></a></pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="">
<div class="">でアクセスできます。</div>
</div>
</div>
</div>
</div>
<hr data-start="1141" data-end="1144" />
<h2 data-section-id="1ffy165" data-start="1146" data-end="1164"><span id="toc6">indexファイルの特別な扱い</span></h2>
<p data-start="1166" data-end="1199">多くの環境では、<br data-start="1174" data-end="1177" /><code data-start="1177" data-end="1184">index</code> ファイルは特別扱いされます。</p>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">

<a rel="noopener" href="http://localhost/sample/" title="&#28961;&#21177;&#12394;URL&#12391;&#12377;" class="blogcard-wrap external-blogcard-wrap a-wrap cf" target="_blank"><div class="blogcard external-blogcard eb-left cf"><div class="blogcard-label external-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail external-blogcard-thumbnail"><img loading="lazy" decoding="async" src="https://s.wordpress.com/mshots/v1/http%3A%2F%2Flocalhost%2Fsample%2F?w=160&#038;h=90" alt="" class="blogcard-thumb-image external-blogcard-thumb-image" width="160" height="90" /></figure><div class="blogcard-content external-blogcard-content"><div class="blogcard-title external-blogcard-title">&#28961;&#21177;&#12394;URL&#12391;&#12377;</div><div class="blogcard-snippet external-blogcard-snippet"></div></div><div class="blogcard-footer external-blogcard-footer cf"><div class="blogcard-site external-blogcard-site"><div class="blogcard-favicon external-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=http://localhost/sample/" alt="" class="blogcard-favicon-image external-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain external-blogcard-domain">localhost</div></div></div></div></a></pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="">
<div class="">とアクセスすると、</div>
</div>
</div>
</div>
</div>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">
<pre class="cm-content q9tKkq_readonly">/sample/index.html</pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="">
<div class="">が自動で表示されます。</div>
</div>
</div>
</div>
</div>
<hr data-start="1295" data-end="1298" />
<h2 data-section-id="1jpnbm9" data-start="1300" data-end="1313"><span id="toc7">よくある構成パターン</span></h2>
<p data-start="1315" data-end="1328">実務でもよく使う構成です。</p>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">
<pre class="cm-content q9tKkq_readonly">/htdocs/
index.php
css/
js/
images/</pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="">
<div class="">URLは、</div>
</div>
</div>
</div>
</div>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">

<a rel="noopener" href="http://localhost/css/style.css" title="&#28961;&#21177;&#12394;URL&#12391;&#12377;" class="blogcard-wrap external-blogcard-wrap a-wrap cf" target="_blank"><div class="blogcard external-blogcard eb-left cf"><div class="blogcard-label external-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail external-blogcard-thumbnail"><img loading="lazy" decoding="async" src="https://s.wordpress.com/mshots/v1/http%3A%2F%2Flocalhost%2Fcss%2Fstyle.css?w=160&#038;h=90" alt="" class="blogcard-thumb-image external-blogcard-thumb-image" width="160" height="90" /></figure><div class="blogcard-content external-blogcard-content"><div class="blogcard-title external-blogcard-title">&#28961;&#21177;&#12394;URL&#12391;&#12377;</div><div class="blogcard-snippet external-blogcard-snippet"></div></div><div class="blogcard-footer external-blogcard-footer cf"><div class="blogcard-site external-blogcard-site"><div class="blogcard-favicon external-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=http://localhost/css/style.css" alt="" class="blogcard-favicon-image external-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain external-blogcard-domain">localhost</div></div></div></div></a>
http://localhost/images/logo.png</pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="">
<div class="">のようになります。</div>
</div>
</div>
</div>
</div>
<hr data-start="1482" data-end="1485" />
<h2 data-section-id="1wh6k4z" data-start="1487" data-end="1500"><span id="toc8">なぜ表示されないのか</span></h2>
<p data-start="1502" data-end="1528">表示されない原因のほとんどは、<br data-start="1517" data-end="1520" />次のどれかです。</p>
<p data-start="1530" data-end="1586">・ドキュメントルート外に置いている<br data-start="1547" data-end="1550" />・URLのパスが間違っている<br data-start="1564" data-end="1567" />・ファイル名が違う（大文字小文字）</p>
<hr data-start="1588" data-end="1591" />
<h2 data-section-id="c5brr0" data-start="1593" data-end="1609"><span id="toc9">よくあるミス①：場所が違う</span></h2>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">
<pre class="cm-content q9tKkq_readonly">/Users/xxx/Desktop/test.html</pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="">
<div class="">ここに置いても、</div>
</div>
</div>
</div>
</div>
<p data-start="1653" data-end="1681">ブラウザからはアクセスできません。</p>
<p data-start="1683" data-end="1710">👉 <strong data-start="1686" data-end="1710">ドキュメントルート内に置く必要があります</strong></p>
<hr data-start="1712" data-end="1715" />
<h2 data-section-id="1709006" data-start="1717" data-end="1733"><span id="toc10">よくあるミス②：パスのズレ</span></h2>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">
<pre class="cm-content q9tKkq_readonly"><span class="ͼ13">&lt;img</span> <span class="ͼ12">src</span><span class="ͼv">=</span><span class="ͼz">"images/sample.jpg"</span><span class="ͼ13">&gt;</span></pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="">
<div class="">なのに、</div>
</div>
</div>
</div>
</div>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">
<pre class="cm-content q9tKkq_readonly">/htdocs/sample/images/sample.jpg</pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="">
<div class="">に置いている場合、</div>
</div>
</div>
</div>
</div>
<p data-start="1841" data-end="1857">👉 パスがズレて表示されません</p>
<hr data-start="1859" data-end="1862" />
<h2 data-section-id="mjwnrx" data-start="1864" data-end="1881"><span id="toc11">よくあるミス③：大文字小文字</span></h2>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">
<pre class="cm-content q9tKkq_readonly">sample.jpg</pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="">
<div class="">と</div>
</div>
</div>
</div>
</div>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">
<pre class="cm-content q9tKkq_readonly">Sample.jpg</pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="">
<div class="">は別ファイルです。</div>
</div>
</div>
</div>
</div>
<p data-start="1945" data-end="1977">特に本番環境（Linux）では<br data-start="1960" data-end="1963" /><strong data-start="1963" data-end="1977">厳密に区別されます。</strong></p>
<hr data-start="1979" data-end="1982" />
<h2 data-section-id="1oc8arx" data-start="1984" data-end="1995"><span id="toc12">相対パスとの関係</span></h2>
<p data-start="1997" data-end="2035">3章で学ぶ「相対パス」は、<br data-start="2010" data-end="2013" />このドキュメントルート理解が前提になります。</p>
<p data-start="2037" data-end="2041">例えば、</p>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">
<pre class="cm-content q9tKkq_readonly"><span class="ͼ13">&lt;img</span> <span class="ͼ12">src</span><span class="ͼv">=</span><span class="ͼz">"images/sample.jpg"</span><span class="ͼ13">&gt;</span></pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="">
<div class="">は、</div>
</div>
</div>
</div>
</div>
<p data-start="2090" data-end="2110">👉 <strong data-start="2093" data-end="2110">今いるファイルから見た位置</strong></p>
<p data-start="2112" data-end="2119">を意味します。</p>
<hr data-start="2121" data-end="2124" />
<h2 data-section-id="13y6dbf" data-start="2126" data-end="2136"><span id="toc13">PHPとの関係</span></h2>
<p data-start="2138" data-end="2151">PHPでも同じ考え方です。</p>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">
<pre class="cm-content q9tKkq_readonly">include 'header.php';</pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="">
<div class="">これは、</div>
</div>
</div>
</div>
</div>
<p data-start="2193" data-end="2214">👉 <strong data-start="2196" data-end="2214">現在のファイルからの相対位置</strong></p>
<p data-start="2216" data-end="2228">を基準に読み込まれます。</p>
<hr data-start="2230" data-end="2233" />
<h2 data-section-id="qtqc6a" data-start="2235" data-end="2248"><span id="toc14">実践：確認してみよう</span></h2>
<p data-start="2250" data-end="2265">次の構成を作ってみてください。</p>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">
<pre class="cm-content q9tKkq_readonly">/htdocs/
test/
index.html</pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="">
<div class="">HTMLの中身：</div>
</div>
</div>
</div>
</div>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">
<pre class="cm-content q9tKkq_readonly"><span class="ͼ13">&lt;h1&gt;</span>テストページ<span class="ͼ13">&lt;/h1&gt;</span></pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="">
<div class="">アクセス：</div>
</div>
</div>
</div>
</div>
<div class="relative w-full mt-4 mb-1">
<div class="">
<div class="relative">
<div class="h-full min-h-0 min-w-0">
<div class="h-full min-h-0 min-w-0">
<div class="border border-token-border-light border-radius-3xl corner-superellipse/1.1 rounded-3xl">
<div class="h-full w-full border-radius-3xl bg-token-bg-elevated-secondary corner-superellipse/1.1 overflow-clip rounded-3xl lxnfua_clipPathFallback">
<div class="">
<div class="relative z-0 flex max-w-full">
<div id="code-block-viewer" class="q9tKkq_viewer cm-editor z-10 light:cm-light dark:cm-light flex h-full w-full flex-col items-stretch ͼs ͼ16" dir="ltr">
<div class="cm-scroller">

<a rel="noopener" href="http://localhost/test/" title="&#28961;&#21177;&#12394;URL&#12391;&#12377;" class="blogcard-wrap external-blogcard-wrap a-wrap cf" target="_blank"><div class="blogcard external-blogcard eb-left cf"><div class="blogcard-label external-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail external-blogcard-thumbnail"><img loading="lazy" decoding="async" src="https://s.wordpress.com/mshots/v1/http%3A%2F%2Flocalhost%2Ftest%2F?w=160&#038;h=90" alt="" class="blogcard-thumb-image external-blogcard-thumb-image" width="160" height="90" /></figure><div class="blogcard-content external-blogcard-content"><div class="blogcard-title external-blogcard-title">&#28961;&#21177;&#12394;URL&#12391;&#12377;</div><div class="blogcard-snippet external-blogcard-snippet"></div></div><div class="blogcard-footer external-blogcard-footer cf"><div class="blogcard-site external-blogcard-site"><div class="blogcard-favicon external-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=http://localhost/test/" alt="" class="blogcard-favicon-image external-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain external-blogcard-domain">localhost</div></div></div></div></a></pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="">
<div class="">これが表示されれば、</div>
</div>
</div>
</div>
</div>
<p data-start="2394" data-end="2415">理解はOKです。</p>
<hr data-start="2417" data-end="2420" />
<h2 data-section-id="1huqhjm" data-start="2422" data-end="2428"><span id="toc15">まとめ</span></h2>
<p data-start="2430" data-end="2442">ドキュメントルートとは、</p>
<p data-start="2444" data-end="2466">👉 <strong data-start="2447" data-end="2466">Webから見える基準のフォルダ</strong></p>
<p data-start="2468" data-end="2471">です。</p>
<p data-start="2473" data-end="2481">そしてURLは、</p>
<p data-start="2483" data-end="2505">👉 <strong data-start="2486" data-end="2505">その中のどこにあるかを表すもの</strong></p>
<p data-start="2507" data-end="2510">です。</p>
<p data-start="2512" data-end="2521">この理解があれば、</p>
<p data-start="2523" data-end="2573">・ファイル配置で迷わない<br data-start="2535" data-end="2538" />・パスエラーで詰まらない<br data-start="2550" data-end="2553" />・PHPやCSSの読み込みで困らない</p>
<p data-start="2575" data-end="2583">状態になります。</p>
<hr data-start="2585" data-end="2588" />
<h2 data-section-id="iedzut" data-start="2590" data-end="2601"><span id="toc16">次に読むべき記事</span></h2>
<p data-start="2603" data-end="2639">▶ 次の記事<br data-start="2609" data-end="2612" /><a href="https://seek-rise.com/web-development/setup/post-327/">2-6 PHPが正しく動作しているか確認してみよう</a></p>
<p data-start="2641" data-end="2666">▶ 関連記事<br data-start="2647" data-end="2650" /><a href="https://seek-rise.com/web-development/html/post-338/">3-4 リンクと画像の使い方</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://seek-rise.com/web-development/setup/post-259/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">259</post-id>	</item>
	</channel>
</rss>
