Webサイトの階層について。
ドメインのルートディレクトリに、たくさんのphpファイルを置いておくのがあまり綺麗でないと思いまして、
ルートにindex.phpだけを置いて、下の階層からphpを読み込む方法はないでしょうか?
サイトは英語サイトと、日本語サイトで分けているので、
以下のように役割ごとフォルダに分けて配置したいと考えています。
/public_html フォルダ (ドメインのルートディレクトリ)
--index.php - ルートに置いたindex
--_enフォルダ - 英語サイト
--_jpフォルダ - 日本語サイト
--jsフォルダ - 共通のjsスクリプト
--cssフォルダ - 共通のcss
--imgフォルダ - 共通のimg
:
その他 faviconやsitemapなど
メインは日本語サイトにしたいので、例えば、
http://hoge.com とURLに打ち込んだときは、_jp配下のindex.phpが表示される。
http://hoge.com/_enと打ち込んだときは、_en配下のindex.phpが表示される。
以下、
http://hoge.com/categoryとしたら、 _jp配下のcategory.php が表示される。
このような感じの設定ができたらと思っています。
サーバはnginxで動かしています。
詳しい方、よろしくお願いいたします。
ちなみに、
現在のnginx.confは、以下のようにしていて、ルートディレクトリ直下に、phpをずらずら並べています。(抜粋)
server { listen 80 default_server; listen [::]:80 default_server; server_name urbanmeetup.tokyo; root /usr/share/nginx/urbanmeetup/public_html; location / { index index.html index.php index.html; try_files $uri $uri.php $uri.html $uri/ 404.html=404; gzip_static on; if ( -f $request_filename.php ) { rewrite ^(.*)$ $1.php; } } location ~ .php$ { root /usr/share/nginx/urbanmeetup/public_html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/10/09 01:47
退会済みユーザー
2017/10/09 02:35