简体   繁体   中英

Remove “index.php” from URL

I have this link

localhost/MySite/queues/index.php

index.php has been removed using .htaccess and I got URL as follows.

localhost/MySite/queues

Now the problem is, when I use segment in my index function like this:

queues.php --> controller

function index($sgmnt = 'test'){
   $this->load->view('queues_view/'.$sgmnt);
}

I want to have this link

localhost/MySite/queues/test

NOT

localhost/MySite/queues/index.php/test

or I can still type

localhost/MySite/queues/index.php/test

but URL must show only

localhost/MySite/queues/test

With the above config setting

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

for this you can take advantage of htaccess.open htaccess and add these lines in to that. i hope it will work( http://localhost/MySite/queues/test ).

RewriteEngine On
RewriteRule ^MySite/queues/test$ /MySite/queues/index.php [L]

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