.htaccess rules in Kohana 3.0?
I'm running a Kohana setup on my local apache server. I've created a 'htdocs' folder which houses the index.php file in the kohana d开发者_运维技巧irectory. So that the system files are not available to visitors. Now I wan't to remove index.php from the URL everytime I visit another controller, so I've tried fooling around with the .htaccess provided but can't get it to work. Anybody here with some skill with this?
The .htaccess file:
# Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase /
# Protect hidden files from being viewed
<Files .*>
Order Deny,Allow
Deny From All
</Files>
# 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]
The file is placed in the kohana directory. Apparently I'm only supposed to alter the RewriteBase variable, but I have no idea on what it should be
RewriteBase basically is the URL from where you are reached.
For example if the URL to index.php is http://yoursite/kohana/index.php you'd set RewriteBase to /kohana.
You can find the docs for mod_rewrite here: http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html
Leave that htaccess as it comes from the package. Your mistake is forgotten config settings in bootstrap. For a site which is located in http://localhost/kohana/ the config settings will be:
Kohana::init(array(
'base_url' => '/kohana/',
'index_file' => '',
));
精彩评论