如何从Kohana 3.1中的URL中删除index.php

lau*_*ent 1 url-routing kohana

目前,使用Kohana 3.1,我可以使用以下方式访问我的控制器:

HTTP://localhost/kohana/index.php/admin

但是,我想在中间没有"index.php"的情况下访问它们,如:

HTTP://本地主机/ Kohana的/管理员

我怎样才能做到这一点?我是否需要更改.htaccess文件或某些配置选项?

我正在使用Kohana提供的.htaccess:

# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /

# Protect hidden files from being viewed

    Order Deny,Allow
    Deny From All


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

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

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

Bla*_*ade 6

但是,如果您使用Rewritebase /kohana/,您仍然会index.php进入网址.我正在使用Kohana 3,所以我去bootstrap.php改变这个:

Kohana::init(array(
    'base_url'   => '/',
    'index_file' => '',
));
Run Code Online (Sandbox Code Playgroud)


The*_*per 5

将RewriteBase指令更改为应用程序所在的位置.你的将是:

# Installation directory
RewriteBase /kohana/
Run Code Online (Sandbox Code Playgroud)

还要确保你base_url的bootstrap中有正确的.