私はこのURL構造を持っています:
proyectos.example.com/ci-doctrine/index.php
proyectos.example.com/ci-doctrine/index.php/welcome
proyectos.example.com/ci-doctrine/index.php/blog
proyectos.example.com/ci-doctrine/admin.php
proyectos.example.com/ci-doctrine/admin.php/welcome
proyectos.example.com/ci-doctrine/admin.php/dashboard
URLについてindex.php
は、次の形式を維持したいと思います。
proyectos.example.com/ci-doctrine/ //default index view
proyectos.example.com/ci-doctrine/welcome
proyectos.example.com/ci-doctrine/blog
したがって、私の .htaccess は次のようになります。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
上記の .htaccess コードは問題なく動作します。admin.php
次のような URL 形式が必要なため、問題は URL に存在します(「管理者」という単語を保持します)。
proyectos.example.com/ci-doctrine/admin
proyectos.example.com/ci-doctrine/admin/dashboard
proyectos.example.com/ci-doctrine/admin/welcome
次に、htaccess を次のように編集しました。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_URI} ^admin/(.*)$ [NC]
RewriteRule ^admin/(.*)$ /admin.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
しかし、ブラウズするproyectos.example.com/ci-doctrine/admin
と 500 エラーが発生するので、管理ファイルのルールが十分に機能していないと思います。
ログ
を確認しましたがerror_log
、アクセスしようとするたびproyectos.example.com/ci-doctrine/admin
に次のメッセージが表示されます。
構成エラーの可能性があるため、要求が 10 個の内部リダイレクトの制限を超えました。必要に応じて、'LimitInternalRecursion' を使用して制限を増やします。「LogLevel debug」を使用してバックトレースを取得します。
リダイレクトのリストが続きます。
[Wed Dec 05 09:47:07 2012] [error] [client 201.192.30.254] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.
[Wed Dec 05 09:47:07 2012] [debug] core.c(3112): [client 201.192.30.254] r->uri = /index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/admin
[Wed Dec 05 09:47:07 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/admin
[Wed Dec 05 09:47:07 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/admin
[Wed Dec 05 09:47:07 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/admin
[Wed Dec 05 09:47:07 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/admin
[Wed Dec 05 09:47:07 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/admin
[Wed Dec 05 09:47:07 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /index.php/proyectos/index.php/proyectos/index.php/proyectos/index.php/admin
[Wed Dec 05 09:47:07 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /index.php/proyectos/index.php/proyectos/index.php/admin
[Wed Dec 05 09:47:07 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /index.php/proyectos/index.php/admin
[Wed Dec 05 09:47:07 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /index.php/admin
[Wed Dec 05 09:47:07 2012] [debug] core.c(3118): [client 201.192.30.254] redirected from r->uri = /ci-doctrine/admin
ディレクトリ構造
ポルパスのトラブルシューティングについては、以下に私のディレクトリ構造を見つけることができます
public_html/
.htaccess/
index.php
proyectos/
ci-doctrine/
.htaccess
index.php
admin.php
ドキュメントルート .htaccess
ルートには、サブドメインと同様にアプリケーションの別のインストールがあります。proyectos.example.com/ci-doctrine
このためindex.php
、URL に同じルールを適用しています。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
更新 > 作業コード
まあ、@ anubhavaの助けを借りて、私はこの仕事を得ました:
ドキュメント ルート .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
サブドメイン .htaccess:
# If the user types "index.php" or "admin.php".
RewriteCond $1 !^(index\.php|admin\.php|images|robots\.txt)
# If the user types just "admin".
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^admin$ admin\.php [L,QSA]
# If the user enter in any admin section, like "admin/section".
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^admin\/(.*)$ admin\.php/$1 [L,QSA]
# If the user types any site section, like "site/section".
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index\.php/$1 [L,QSA]