Kohana V3 中用于多个应用程序的 .htaccess

发布于 2024-09-28 06:11:30 字数 1357 浏览 5 评论 0原文

您好,我在 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)

是这样访问前端示例 url:

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

并访问管理站点;

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

任务是,我想使用.htaccess(mod_rewrite)删除并用/admin/替换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]

Hi I have setup multiple application in Kohana v3, it works normally without enabling .htaccess (to remove index.php or admin.php)

my setup

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

so to access the frontend sample url will be;

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

and to access administration site;

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

The task is, I want to remove and replace index.php (default url) and admin.php with /admin/ using .htaccess (mod_rewrite) so it can be

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

my current .htaccess (not working) is;

# 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]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暮光沉寂 2024-10-05 06:11:30

通常 RewriteBase 参数是 '/' 而不是 '/ko3/' - 它是您的 webroot 中的文件夹名称。另请检查网络服务器的配置是否支持 modrewrite。

Usually RewriteBase param is '/' instead of '/ko3/' - its a folder name in your webroot. Also check webserver's configuration for modrewrite support.

×眷恋的温暖 2024-10-05 06:11:30
# 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]
# 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]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文