<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>公開url変更 on qwerty.work</title>
        <link>https://qwerty.work/tags/%E5%85%AC%E9%96%8Burl%E5%A4%89%E6%9B%B4/</link>
        <description>Recent content in 公開url変更 on qwerty.work</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>ja-JP</language>
        <lastBuildDate>Tue, 29 Nov 2022 00:00:00 +0000</lastBuildDate><atom:link href="https://qwerty.work/tags/%E5%85%AC%E9%96%8Burl%E5%A4%89%E6%9B%B4/index.xml" rel="self" type="application/rss+xml" /><item>
            <title>【Wordpress】公開URLを別階層のディレクトリに変更したいとき</title>
            <link>https://qwerty.work/post/2022/11/wordpress%E5%85%AC%E9%96%8Burl%E3%82%92%E5%88%A5%E9%9A%8E%E5%B1%A4%E3%81%AE%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%E3%81%AB%E5%A4%89%E6%9B%B4%E3%81%97%E3%81%9F/</link>
            <pubDate>Tue, 29 Nov 2022 00:00:00 +0000</pubDate>
            <guid>https://qwerty.work/post/2022/11/wordpress%E5%85%AC%E9%96%8Burl%E3%82%92%E5%88%A5%E9%9A%8E%E5%B1%A4%E3%81%AE%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%E3%81%AB%E5%A4%89%E6%9B%B4%E3%81%97%E3%81%9F/</guid>
            <description>&lt;p&gt;Wordpressを&lt;code&gt;/wp&lt;/code&gt;のディレクトリにインストールして、公開はルートのURLでしたいというのはよくある話で、その方法は検索すれば沢山出てきます。しかし、今回はルートではなく、インストールディレクトリと同階層の別のディレクトリで公開することになりました。そこで、すこし手こずったのでメモ。&lt;/p&gt;&#xA;&lt;figure&gt;&#xA;&lt;p&gt;&lt;img class=&#34;gallery-image&#34; data-flex-basis=&#34;974px&#34; data-flex-grow=&#34;405&#34; height=&#34;167&#34; loading=&#34;lazy&#34; sizes=&#34;(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px&#34; src=&#34;https://qwerty.work/post/2022/11/wordpress%E5%85%AC%E9%96%8Burl%E3%82%92%E5%88%A5%E9%9A%8E%E5%B1%A4%E3%81%AE%E3%83%87%E3%82%A3%E3%83%AC%E3%82%AF%E3%83%88%E3%83%AA%E3%81%AB%E5%A4%89%E6%9B%B4%E3%81%97%E3%81%9F/images/wp-admin_options-general.png&#34; width=&#34;678&#34;&gt;&lt;/p&gt;&#xA;&lt;figcaption&gt;&#xA;&lt;p&gt;[設定] -[一般設定]の画面&lt;/p&gt;&#xA;&lt;/figcaption&gt;&#xA;&lt;/figure&gt;&#xA;&lt;h2 id=&#34;変更手順&#34;&gt;変更手順&#xA;&lt;/h2&gt;&lt;h3 id=&#34;htaccessとindexphpを公開ディレクトリにコピー&#34;&gt;.htaccessとindex.phpを公開ディレクトリにコピー&#xA;&lt;/h3&gt;&lt;p&gt;今回、&lt;code&gt;https://example.com/blog/&lt;/code&gt;というURLでブログを公開する例で説明します。その場合、まずはルートにblogフォルダを作成して、&lt;code&gt;/wp&lt;/code&gt;直下にある**.htaccess&lt;strong&gt;と&lt;/strong&gt;index.php**をコピーして、&lt;code&gt;/blog&lt;/code&gt;直下に貼り付けます。&lt;/p&gt;&#xA;&lt;h3 id=&#34;indexphpを変更&#34;&gt;index.phpを変更&#xA;&lt;/h3&gt;&lt;p&gt;&lt;code&gt;/blog&lt;/code&gt;直下に貼り付けたindex.phpを以下のようにコードを変換します。（example.com/blog/index.php）&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;require __DIR__ . &amp;#39;/wp-blog-header.php&amp;#39;;&#xA;　↓&#xA;require dirname(__DIR__, 1). &amp;#39;/wp/wp-blog-header.php&amp;#39;;&#xA;また&#xA;require dirname(__FILE__, 2). &amp;#39;/wp/wp-blog-header.php&amp;#39;;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;code&gt;dirname(__DIR__, 1)&lt;/code&gt;はこのディレクトリパスから1段上の階層までのパスを取得します。&lt;code&gt;dirname(__FILE__, 2)&lt;/code&gt;はこのファイルパスからファイル名を含めて2段上の階層までを取得するという意味になっています。&lt;code&gt;__DIR__&lt;/code&gt;と&lt;code&gt;__FILE__&lt;/code&gt;で絶対パスと相対パスの使い方に行き詰まり、この方法にたどり着きました。&lt;/p&gt;&#xA;</description>
        </item></channel>
</rss>
