I have this url structure:
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
For index.php urls, I would like to keep this format:
proyectos.example.com/ci-doctrine/ //default index view
proyectos.example.com/ci-doctrine/welcome
proyectos.example.com/ci-doctrine/blog
So, my .htaccess looks like:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
The .htaccess code above works fine. The problem resides for admin.php urls, because I want the urls format like (keeping the ‘admin’ word):
proyectos.example.com/ci-doctrine/admin
proyectos.example.com/ci-doctrine/admin/dashboard
proyectos.example.com/ci-doctrine/admin/welcome
Then, I have editted my htaccess like:
<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>
But when I browse proyectos.example.com/ci-doctrine/admin I get a 500 error, so I suppose that my rule for admin file is not working good enought.
Logs
I have reviewed the error_log, and each time I try to acesss proyectos.example.com/ci-doctrine/admin it prints a message:
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.
Followed by a list of redirections:
[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
Directory structure
For troubleshooting porpuses, below you can find my dir structure
public_html/
.htaccess/
index.php
proyectos/
ci-doctrine/
.htaccess
index.php
admin.php
Document root .htaccess
In the root, I have another installation of my application like in the subdomain proyectos.example.com/ci-doctrine does, for this reason I am applying the same rule for index.php for urls.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
UPDATE > working code
Well, with the help of @anubhava I got this work:
Document root .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>
Subdomain .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]
Actually the problem is one extra (and incorrect) RewriteCond in your first rule. Here is the modified and correct code that should work for you:
EDIT: Your
$DOCUMENT_ROOT/.htaccessshould be modified like this: