Codeigniterアプリケーションは通常、mod_rewriteを使用index.php
してURLから文字列を除外します。同じドメイン内に2つのCodeigniterアプリケーションがあります。1つのCodigniterアプリケーションはWebルートフォルダーにあり、別のCodigniterアプリケーションはWebルートフォルダーのサブフォルダーにあります。
Codeigniterアプリケーション1:
http://domain.com/index.php
Codeigniterアプリケーション2(ランディングページアプリケーション):
http://domain.com/land/index.php
2つのCodeigniterアプリケーションはそれぞれアトミックであり、それらの間でファイルを共有しません。Codeigniterフレームワークのすべてのファイルは、に何public_html/
度もありpublic_html/land/
ます。したがってindex.php
、ルート/
フォルダをアドレス指定するURLの文字列を除外index.php
し、/land/
サブフォルダの文字列も除外する必要があります。
ルートフォルダーの.htaccessファイルは、Codeigniter wikiから広く推奨されているmod_rewriteルール(以下のコード)を使用します。このルールのセットは、ルートCodeigniterアプリケーション(アプリケーション1)で適切に機能します。これらのルールは、Webルートフォルダーにあります。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
ErrorDocument 404 /index.php
</IfModule>
上記の一連のルールはindex.php
、ルートCodeigniterアプリケーションのURLから問題なく削除できます。しかし、この一連のルールでは、mod_rewriteルールの実行が許可されていないようですpublic_html/land/.htaccess
。
のmod_rewriteルールを削除すると、のmod_rewriteルールの評価public_html/.htaccess
がpublic_html/land/.htaccess
開始されます。
サブフォルダーpublic_html/.htaccess
にアクセスすることを目的としたURLの特殊なケースを処理するために、mod_rewriteルールを変更する方法はありますか?/land/
最善の解決策は、mod_rewriteルールを変更して、サブフォルダーがURLでアドレス指定されたときにpublic_html/.htaccess
mod_rewriteルールを実行できるようにすることだと思います。public_html/land/.htaccess
私はどんな提案にもオープンです。
「サブドメインを使用しないのはなぜですか?」という質問に対する先制的な回答。1.SSL証明書の費用を節約します。2)技術者以外のユーザーは、ベースドメイン名をマーケティングするためにサブドメインと混同されることがあります。
「Codeigniterアプリケーションを組み合わせてフレームワークで同じファイルを使用してみませんか?」に対する先制的な答え。フレームワークファイルを複製することは、バージョン管理リポジトリを分離しておくための簡単な方法です。