Welcome Guest, Not a member yet? Register   Sign In
.htaccess and routing
#1

[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!
#2

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

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

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

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

Options +Indexes +FollowSymLinks +ExecCGI
#6

[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.
#7

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

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

[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.




Theme © iAndrew 2016 - Forum software by © MyBB