将Kohana 2.4从根位置转移到可以通过目录访问的问题?

时间:2012-10-05 11:31:57

标签: url-rewriting kohana

我开发了一个kohana项目2.4版本,我已经通过配置虚拟主机开发了我们正在使用某个域aa.com访问它,现在我必须将项目移动到名为kohana的文件夹并通过aa访问它.COM / Kohana的。如果我以这种方式访问​​它,那么我的网址会发生变化,所以css& js文件不包括在内,因为src url我提供了类似/ public / css /所以它不起作用,同样适用于调用控制器。喜欢使用这种格式/ user / login /来调用控制器。现在,当我点击显示像aa.com/user/login这样没有找到的网址,反过来它应该自动像aa.com/kohana/user/login。有没有办法改变htaccess文件或黑客routes.php文件。 ?

我应该能够在网址前自动附加/ kohana /。

请告诉我一个如何实现的方法。

1 个答案:

答案 0 :(得分:0)

是的!

我只是在kohana 3.0之后开始,但你可以改变重写库。

在你的.htacces中它可能会说“rewritebase /”

将其更改为新目录。 “rewritebase / kohana /”

如果2.4有一个引导程序(我不确定)它应该说“base_url”。你改变它与.htaccess相同。 / Kohana的/.

编辑:这是一个例子:

# Turn on URL rewriting
RewriteEngine On

# Installation directory
RewriteBase /kohana/

# Protect application and system files from being viewed
RewriteRule ^(application|modules|system) - [F,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,L]