CodeIgniter Forums
.htaccess and routing - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: .htaccess and routing (/thread-57343.html)



.htaccess and routing - El Forum - 03-07-2013

[eluser]ibnclaudius[/eluser]
I want to send the parameter like:

Quote:http://localhost/index.php/myparameter

so I made this routing:

Code:
$route['(:any)'] = 'events/event/$1';

cause my main controller is something like:

Code:
class Events extends CI_Controller {

    public function index()
    {}

    public function event()
    {}

}

until this point everything works, but the error starts when trying to remove the index.php from the url, by creating this .htaccess:

Code:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

and removing the index.php from:

Code:
$config['index_page'] = 'index.php';

but when I try to access an url like http://localhost/myparameter I get a not found! :S And yes, mod_rewrite is enabled!


.htaccess and routing - El Forum - 03-08-2013

[eluser]Harold Villacorte[/eluser]
This works for me, basically just add the Query String Append.
Code:
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]



.htaccess and routing - El Forum - 03-08-2013

[eluser]ibnclaudius[/eluser]
Now I'm having again the problem with 403 Forbidden when trying to use .htaccess =/


.htaccess and routing - El Forum - 03-08-2013

[eluser]Harold Villacorte[/eluser]
It could be the read permission of the .htaccess file. It has to be readable.


.htaccess and routing - El Forum - 03-08-2013

[eluser]ibnclaudius[/eluser]
Solved the 403 Forbidden by adding:

Options +Indexes +FollowSymLinks +ExecCGI


.htaccess and routing - El Forum - 03-08-2013

[eluser]ibnclaudius[/eluser]
[quote author="Harold Villacorte" date="1362773807"]This works for me, basically just add the Query String Append.
Code:
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
[/quote]

When trying to access the url using your .htaccess:

http://localhost/myparameter

i get this error:

The requested URL /Users/ibnclaudius/Sites/ibnight/index.php/1 was not found on this server.


.htaccess and routing - El Forum - 03-08-2013

[eluser]Harold Villacorte[/eluser]
Mabe you should try some different rewrite patterns:
Code:
./index.php/$1
/index.php/$1
index.php/$1



.htaccess and routing - El Forum - 03-08-2013

[eluser]ibnclaudius[/eluser]
Still not found. =/


.htaccess and routing - El Forum - 03-08-2013

[eluser]Harold Villacorte[/eluser]
I can't say I know where your problem is, this all would work for me. Maybe someone else will jump in, cheers.