简体   繁体   中英

Remove index.php from URLs in Kohana 2.x

I want to configure Kohana 2.x to have links in this format:

http://localhost/mysite/web/admin/support

instead of this:

http://localhost/mysite/web/admin/index.php/support

I removed the index.php from the config.php file ( $config['index_page'] = '';) and I added the following line in the .htaccess file:

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

If you hover above a link you can see that the links are like I wanted them but there is always this error:

Not Found
The requested URL /mysite/web/admin/support was not found on this server

I don't know how to change the configuration like I want to.

Write following code in htaccess::

RewriteEngine On

RewriteBase /

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

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

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

you can also change the config.php file to:

$config['index_page'] = '';

another one try

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule !^index\.php index.php%{REQUEST_URI} [L]  

try more solution then see
How to set up .htaccess for Kohana correctly, so that there is no ugly "index.php/" in the URL?
see also following tuts::
http://kohanaframework.org/3.0/guide/kohana/tutorials/clean-urls

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM