我正在本地 apache 服务器上运行 Kohana 设置。我创建了一个“htdocs”文件夹,其中包含 kohana 目录中的 index.php 文件。这样系统文件就无法被访问者访问。现在,我不想每次访问另一个 Controller 时都从 URL 中删除 index.php,因此我尝试使用提供的 .htaccess 进行操作,但无法使其正常工作。这里有人有这方面的技能吗?
.htaccess 文件:
# 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]
该文件放置在 kohana 目录中。显然我只应该更改 RewriteBase 变量,但我不知道它应该是什么
最佳答案
RewriteBase 基本上是到达您的 URL。
例如,如果index.php的URL是http://yoursite/kohana/index.php您可以将 RewriteBase 设置为/kohana。
您可以在此处找到 mod_rewrite 的文档:http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html
关于php - Kohana 3.0 中的 .htaccess 规则?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3000904/