【问题标题】:kohana htaccess and index structurekohana htaccess 和索引结构
【发布时间】:2012-06-01 06:06:26
【问题描述】:

我正在使用 kohana 3.2

我的网站是 www.mysite.com/best,kohana 安装在 best。

我正在使用带有 rewritebase /best 的默认 htaccess 文件

那么重定向访问 www.mysite.com 的用户的最佳方式是什么?

现在如果有人把 www.mysite.com/helo (www.mysite.com/best/helo) 它加载但 apache 给出 404 未找到。

我希望我的问题是有道理的。

编辑

如果用户访问主域 (www.mysite.com),我希望它加载位于 mysite/best 的 kohana。 但是如果用户现在输入完整的内容并省略了最佳内容,则站点将加载但我的表单将无法正常工作,因为它发布到 www.mysite.com/helo 而不是 www.mysite.com/best/helo 它必须显示一个未找到的页面,而不是加载假的 helo 控制器。

编辑

好的,我将它添加到 htaccess 文件中,它运行良好

RewriteCond %{REQUEST_URI} !^/best/

RewriteRule ^(.*)$ /best/$1

【问题讨论】:

  • 给我们您的完整 .htaccess 文件。加载 www.mysite.com/best 工作吗? www.mysite.com/best/index.php/helo 工作吗?
  • 这是 kohana 自带的标准 htaccess 文件。是的,两者都有效。如果用户输入 www.mysite.com,它会显示一个未加载 index.html 的文件夹列表。如果他们把 www.mysite.com/best 它加载 kohana index.php。现在,如果他们将它与控制器一起使用,那么最好省略它,但它的标题和标题在 firebug 中说 PAGE NOT FOUND

标签: php .htaccess kohana


【解决方案1】:

你不能在 htaccess 中有多个 rewritebase 所以...... 重写你的规则以适应你在 /best 中的需要 或将其他 htaccess 放入 / 以重写您的需求。

【讨论】:

    【解决方案2】:

    试试这个 .htaccess:

    # Turn on URL rewriting
    RewriteEngine On
    
    # Installation directory
    RewriteBase /best/
    
    # 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?kohana_uri=$0 [PT,L,QSA]
    RewriteRule .* index.php?/$0 [PT,L,QSA]
    

    请注意,RewriteBase 上的尾随 / 是必需的。

    【讨论】:

      猜你喜欢
      • 2010-11-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多