.htaccess在Kohana V3中进行多次应用

时间:2010-10-20 10:17:29

标签: mod-rewrite kohana-3

您好我在Kohana v3中设置了多个应用程序,它正常工作而没有启用.htaccess(删除index.php或admin.php)

我的设置

+ system/
+ modules/
+ applications/
  + public/
    + bootstrap.php
    + ...
  + admin/
    + bootstrap.php
    + ...
+ index.php (for 'public' application)
+ admin.php (for 'admin' application)

所以访问前端示例网址将是;

http://mydomain.com/index.php/(controller_name)/...

并访问管理网站;

http://mydomain.com/admin.php/(controller_name)/...

任务是,我想删除并用/ admin /使用.htaccess(mod_rewrite)替换index.php(默认url)和admin.php,这样就可以

http://mydomain.com/(controller_name)           <- 'public' application
http://mydomain.com/admin/(controller_name)     <- 'admin' application

我当前的.htaccess(不工作)是;

# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /ko3/

# Protect hidden files from being viewed

    Order Deny,Allow
    Deny From All


# Protect application and system files from being viewed
RewriteRule ^(?:web-apps|modules|core)\b.* index.php/$0 [L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# TODO: rewrite admin URL to admin.php/URL
#RewriteRule ^admin/(.*) admin.php/$0 [L]

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]

2 个答案:

答案 0 :(得分:0)

通常RewriteBase参数是'/'而不是'/ ko3 /' - 它是webroot中的文件夹名称。还要检查webserver的modrewrite支持配置。

答案 1 :(得分:0)

# Catch every request for admin 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all URLs to admin.php/URL
RewriteRule ^admin/(.*) admin.php/$1 [PT,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT,L]