php - Kohana 3.0 中的 .htaccess 规则?

标签 php apache .htaccess mod-rewrite kohana

我正在本地 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/

相关文章:

php - 在 PHP 中匹配关键字

java - Log4j StringMatchFilter 和 denyAll 过滤器属性配置

php - 检查是否存在定义变量-PHP中的警告错误

javascript - 删除(取消设置)今天之前创建的所有较旧的 cookie 并在浏览器历史记录中保留子目录?

php - 如何将url参数写入.htaccess

PHP 代码适用于共享主机,但不适用于 Xampp

php - Laravel 5.2 - 更改从 Eloquent 获取的数据格式

php - 在不通过网络浏览器进行清理的情况下查看访问日志是否危险?

php - 让 mod_rewrite 传递 $_GET 参数?

php - Htaccess 仅用于友好的 url