开发者

Ko3 - URL Rewriting problem - Removing index.php

I'm developing a website using Kohana 3 (1rst time I use a framework). Locally, everything works perfectly. At the moment, I have a default template controller, a multi-language support and my 'index.php' is correctly removed. So before going further, I tested if it worked on my server and I got an endless loop.

I followed the tutorial from the unofficial wiki for the multi-language implementation: http://www.kerkness.ca/wiki/doku.php?id=example_of_a_multi-language_website

A redirection to the default language occurs if the language is not specified in the uri so I figured the problem might have come from there even though it worked locally, so I removed it to see what happens without the redirection. Now, I can see my home page, but whatever the uri is in the web browser, the home page will always be called. I inserted the following line in my home view to check what the uri was: request::instance()->uri() and effectively, the uri is always: /en/home/

I put the index.php back (in the bootstrap) and everything worked fine again, even with the redirection to the default language.

My first guess was that the uri isn't rewritten corre开发者_开发知识库ctly, so I tried to change the .htaccess but no success...

Here's my .htaccess:

# Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase /dev/
# 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)/ - [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]

(btw I also tried the other RewriteRule in the unofficial wiki, doesn't work either)

Additional info: Host: WebHostingPad Apache: v2.2.11 PHP: 5.2.9

Rewrite_Module is activated

Thank you, I would really appreciate your help because I've been trying to fix this for days now and it's really starting to annoy me ;)


The only thing you have to change in order to get rid of index.php in URL is to set the 'index_file' param in Kohana::init ( bootstrap.php ) to FALSE ( everything else can cause an error ).

So the Kohana::init looks like this;

Kohana::init(array(
    'base_url'      => '/',
    'index_file'    => FALSE,

));

If it worked with the original .htaccess, there's no need to change it at all.


The problem came from $_SERVER['PATH_INFO'] which returned no value...

This issue can be solved by adding the following line to the php.ini:

cgi.fix_pathinfo=0
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜