I have a problem with hiding part of url in Kohana 3.
There are controlers stored in admin subfolder. These controlers power admin panel of site. So when I type :
http://mysite.xyz/admin
it works ok. I need only admin panel of that kohana project, and I decided to create subdomain admin
.
So now when I type:
http://admin.mysite.xyz/admin
it works ok.
But I want to hide that admin
part of url and when I will type:
http://admin.mysite.xyz
I will not load kohana site, but admin panel.
Here is my .htaccess:
RewriteEngine On
RewriteBase /
###### Add trailing slash (optional) ######
RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+[^/])$ %{REQUEST_URI}/ [L,R=301,NE]
RewriteCond %{REQUEST_METHOD} !POST
RewriteRule ^(.*)index.php/(.*)$ /$1$2 [R=301,L,NE]
RewriteCond $1 ^(index\.php|robots\.txt|favicon\.ico|media)
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?kohana_uri=$1 [L,QSA]
RewriteCond %{HTTP_HOST} ^(www.)?admin.schoener-tauchen.pl$
RewriteRule ^(/)?$ admin [L]
RewriteRule ^admin/(.+)$ $1 [L,NC,R]
It doesn't work. It gives 404 error.
Can someone help, please?
PS. Changing Kohana routing is unfortunately very complicated in this case. Htaccess changes seems to be easier.
EDIT
bootstrap.php route:
Route::set('admin', 'admin(/<controller>(,<action>(,<id>)(,<id2>)(,<id3>)))')
->defaults(array(
'directory' => 'admin',
'controller' => 'home',
'action' => 'index',
));
Route::set('default', '(<controller>(,<action>(,<id>)))', array('controller'=>'\w+','controller'=>'\w+', 'action'=>'\w+', 'param' => '.+'))
->defaults(array(
'directory' => 'admin',
'controller' => 'home',
'action' => 'index',
));
Ok. I solved it by the hack in .htaccess:
RewriteRule ^admin/(.+)$ $1 [L,NC,R]
In view's files and controllers there are links, URLs which contain that admin
. Htaccess force it to skip that admin
part.