views:

2973

answers:

6

After 2 hours now I couldn't get it right.

The Kohana installation is accessible directly under my domain, i.e. "http://something.org/"

Instead of http://something.org/index.php/welcomde/index I want to have URLs like http://something.org/welcome/index

My .htaccess is messed up completely. It's actually the standard example.htaccess that came with the download. It's almost useless. On the kohana page is a tutorial "how to remove the index.php". It's really useless as well, since it will not even talk about how to remove it. Totally confusing.

Please, can someone provide his working .htaccess for a standard kohana installation?

+2  A: 

Try this mod_rewrite rule:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !^index\.php index.php%{REQUEST_URI} [L]
Gumbo
That doesn't work...
Thanks
And that does what mean? Have you already read http://kohanaphp.com/tutorials/remove_index
Gumbo
There comes the "input error" message (white page). Yes, I did. They don't talk about how to remove it, although the title promises it. They totally forgot about it during the article. It's a pitty, really.
Thanks
+1  A: 

On some hosts, I think specficially when running PHP in CGI mode, you have to change

RewriteRule ^(.*)$ index.php/$1 [L]

to

RewriteRule ^(.*)$ index.php?/$1 [L]

in your htaccess. So basically you can use the kohana recommended setup, simply replacing index.php/$1 with index.php?/$1

Dylan
It doesn't work. Tried both. config.php has that index_page = ''. Still I can only come to an working controller if I put that index.php/foo inside the URL :/
Thanks
Hrm, the "No input file specified" is the exact error that adding the question mark usually fixes. Just to clarify, this fix was for htaccess only, nothing in the config.php file.
Dylan
+2  A: 

This is our .htaccess file right now, and it seems to be working.

RewriteEngine On

# 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]

Note that we have our application, system and modules directories all outside of the web root.

notJim
+2  A: 

My htaccess looks like the example.

RewriteEngine On

RewriteBase /

RewriteRule ^(application|modules|system) - [F,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule .* index.php/$0 [PT,L]

But you also have to change the config.php file to:

$config['index_page'] = '';
Ambirex
What's the - [F,L] and [PT,L] thing doing?
Thanks
See the apache manual:http://httpd.apache.org/docs/2.2/rewrite/rewrite_flags.html"F|forbiddenUsing the [F] flag causes Apache to return a 403 Forbidden status code to the client. ""L|lastThe [L] flag causes mod_rewrite to stop processing the rule set. In most contexts, this means that if the rule matches, no further rules will be processed.""PT|passthroughThe target (or substitution string) in a RewriteRule is assumed to be a file path, by default."
Ambirex
I've set the index_page to '' in application/config/config.php, and used exactly the same .htaccess. I'm still getting this message when leaving away the index.php/ in my URL: "No input file specified"... very strange
Thanks
Ambirex
That was the solution! I've got a stone old server ;)
Thanks
+1  A: 

I suggest you to give a look at this link: http://codeigniter.com/wiki/mod_rewrite/

Given that Kohana is a fork of CodeIgniter, you'll maybe fix with this; it worked for me (on CodeIgniter).

avastreg
FYI, Kohana started as a fork but has since been completely rewritten.
Ambirex
yes you're right, in fact mine was a suggestion or something like. I suppose that starting from the same base (also if different) that link would help.
avastreg
A: 

For those who get "forbidden error" 403 on OSX with default .htaccess be sure to add as the first line in .htaccess

Options +FollowSymLinks

Marcin Ignac