Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

[SOLVED] Kohana, Can't Remove Index.php From Urls?

kohana framework url

  • This topic is locked This topic is locked
9 replies to this topic

#1 Stasonix

Stasonix

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 115 posts
  • Programming Language:C++, PHP, JavaScript, Delphi/Object Pascal, Pascal
  • Learning:C++, PHP, JavaScript, Delphi/Object Pascal

Posted 12 May 2012 - 08:28 AM

php 5.4.3 (cgi)

Apache 2.2

kohana 3.2.0

Hope this forum branch is a right place for my topic, 'caz it's more a server apache configuration troubleshooting. So here is mine config of .htaccess of kohana:


RewriteEngine On

RewriteBase /kohana/

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

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

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

nothing excited.

Next:

in bootstrap.php I add 'index_file' => FALSE in.. you know where.

So it doesn't works anyway. I'm trying to go by http://kohana.loc/welcome/test and it's return me an error:
The requested URL /welcome/test was not found on this server.

I have a feel that .htaccess absolutely doesn't work, look like apache can't find this file, so I did it:

Added to http.conf:


<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^(/index\.php|/img|/js|/css|/robots\.txt|/favicon\.ico)
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>

I restart my apache and still nothing works for me. I stuck.
  • 0

#2 tavich

tavich

    CC Addict

  • Senior Member
  • PipPipPipPipPip
  • 399 posts
  • Location:Delaware
  • Programming Language:C#
  • Learning:C++, PHP, JavaScript

Posted 12 May 2012 - 08:52 AM

I don't know much among the technical term's of apache. But this is strange. Are you using a cp such as cpanel where you can change which file is the index?
  • 0
Send a like my way if I helped you or if you found my post useful or even just enjoyed reading my post.
Thank you :)

#3 Stasonix

Stasonix

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 115 posts
  • Programming Language:C++, PHP, JavaScript, Delphi/Object Pascal, Pascal
  • Learning:C++, PHP, JavaScript, Delphi/Object Pascal

Posted 12 May 2012 - 09:24 AM

I use Kohana framework on my local server (installation php+mysql+apache). The file index.php (in the URL) I can change only in apache configuration file - httpd.conf by adding ModRewrite module. Also it possible to add this (some features) in .htaccess file in the Kohana directory, before it I must edit file bootstrap.php:

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

I did all recommendations on the official page of Kohana to get rid of index.php in the URL, but it is still there.
  • 0

#4 tavich

tavich

    CC Addict

  • Senior Member
  • PipPipPipPipPip
  • 399 posts
  • Location:Delaware
  • Programming Language:C#
  • Learning:C++, PHP, JavaScript

Posted 12 May 2012 - 09:44 AM

Did you try clearing your cookies?
  • 0
Send a like my way if I helped you or if you found my post useful or even just enjoyed reading my post.
Thank you :)

#5 Stasonix

Stasonix

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 115 posts
  • Programming Language:C++, PHP, JavaScript, Delphi/Object Pascal, Pascal
  • Learning:C++, PHP, JavaScript, Delphi/Object Pascal

Posted 12 May 2012 - 12:26 PM

Jesus, ThatOneGuy don't answer on my this post pls., you don't have a clue what I am talking about. Thanks anyway.
  • 0

#6 tavich

tavich

    CC Addict

  • Senior Member
  • PipPipPipPipPip
  • 399 posts
  • Location:Delaware
  • Programming Language:C#
  • Learning:C++, PHP, JavaScript

Posted 12 May 2012 - 12:36 PM

I do understand what you are talking about...When you visit a folder on your localhost the index.php is there or you can only visit it through index.php
Just try clearing your cookies. Cookies are like little save files for certain websites. Cookies CAN make you only visit the website through index.php or make it show through index.php
If not, then your title is misleading.
  • 0
Send a like my way if I helped you or if you found my post useful or even just enjoyed reading my post.
Thank you :)

#7 Stasonix

Stasonix

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 115 posts
  • Programming Language:C++, PHP, JavaScript, Delphi/Object Pascal, Pascal
  • Learning:C++, PHP, JavaScript, Delphi/Object Pascal

Posted 12 May 2012 - 12:48 PM

Kohana doesn't uses cookie by itself, only I can create a cookie. Seems it's not a php question.
  • 0

#8 papabear

papabear

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 472 posts
  • Location:DarkSide

Posted 12 May 2012 - 02:20 PM

Where you run your apache? in a webhost? or your localhost running wamp? if you are running wamp there is an issue using the RewriteEngine On the mod_rewrite module will not start and it is disabled automatically. Please check it. also try this rewrite rule instead. Also make sure that you have RewriteBase because some server will disregard the rewriterule if you don't have a rewrite base.



# Turn on URL rewriting
RewriteEngine On

# Installation directory. Some server will disregard the rewriterule if you don't have a rewritebase
RewriteBase /

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

after doing that you must also check your bootstrap.php in \application\bootstrap.php and edit your installation of kohana by this



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

edit the base_url in what directory you have installed the kohana framework.

You can also make use of the Kohana Routing, every framework has a routing that you can use to rewrite URLs.

Have fun :)
  • 1
Life has no CTRL+Z
Never Forget To HIT "LIKE" If I Helped

#9 Stasonix

Stasonix

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 115 posts
  • Programming Language:C++, PHP, JavaScript, Delphi/Object Pascal, Pascal
  • Learning:C++, PHP, JavaScript, Delphi/Object Pascal

Posted 12 May 2012 - 02:21 PM

Solved and I want to share my fixes. In the httpd.conf all AllowOverride must be ALL instead of None. And in the end of the config better to add something like this:
<IfModule mod_rewrite>
RewriteEngine On
</IfModule>
Next just use standart .htaccess file (it's example.htaccess, just renamed) assigned to Kohana.
  • 0

#10 papabear

papabear

    CC Devotee

  • Senior Member
  • PipPipPipPipPipPip
  • 472 posts
  • Location:DarkSide

Posted 12 May 2012 - 02:27 PM

Solved and I want to share my fixes. In the httpd.conf all AllowOverride must be ALL instead of None. And in the end of the config better to add something like this:

<IfModule mod_rewrite>
RewriteEngine On
</IfModule>
Next just use standart .htaccess file (it's example.htaccess, just renamed) assigned to Kohana.


I'm glad you solve it :) post up again if you have encounter some problem, Good Luck in using that Framework and build your best application! :cool:
  • 1
Life has no CTRL+Z
Never Forget To HIT "LIKE" If I Helped





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download