Page 1 of 1

.htaccess issues with sub-directory applications

Posted: Tue Nov 24, 2009 7:49 pm
by alex.barylski
I alwasy run into this issue and can never find my old threads...personal KBASE me thinks :)

ANyways I have index.php in my root directory looks something like:

Code: Select all

RewriteEngine on
RewriteBase /
 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,NC,L]
One of the sub-directories is 'admin' which houses various applications which also need to use .htaccess but their own so as to be compartmenaltized (I should be able to drop in an admin application not have to notify the .htaccess in root to forward requests for directory 'admin/something' to it's index.php file.

So the structure lookes like

Code: Select all

index.php
.htaccess
admin
admin/forum/.htaccess
admin/forum/index.php
Unfortunately the later doesn't seem to want to work as the root index.php is being invoked and looking for a resource which doesn't exist.

Anyway around this issue, considering the drop in requirements?

Cheers,
Alex

Re: .htaccess issues with sub-directory applications

Posted: Wed Nov 25, 2009 4:36 am
by Virvo
Change your ROOT .htaccess to:


RewriteCond %{REQUEST_URI} !^admin
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,NC,L]

this says... if the URI doesnt start with 'admin' ... go to index.php, otherwise go to the admin folder and process the request as normal (at which point your admin directory .htaccess would take over)

Re: .htaccess issues with sub-directory applications

Posted: Wed Nov 25, 2009 6:29 pm
by alex.barylski
this says... if the URI doesnt start with 'admin' ... go to index.php, otherwise go to the admin folder and process the request as normal (at which point your admin directory .htaccess would take over)
EDIT | I tried this but still doesn't work:

Code: Select all

http://www.pcspectra.com/admin/system/a ... /.htaccess
 
RewriteEngine on
RewriteBase /
 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,NC,L]

Code: Select all

http://www.pcspectra.com/.htaccess
 
RewriteEngine on
RewriteBase /
 
RewriteCond %{HTTP_HOST} ^pcspectra.com [NC]
RewriteRule ^(.*)$ http://www.pcspectra.com/$1 [L,R=301]
 
RewriteCond %{REQUEST_URI} !^admin
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,NC,L]
Any ideas?

Cheers,
Alex