Welcome Guest, Not a member yet? Register   Sign In
[SOLVED]Segments without index.php
#1

[eluser]Jaketoolson[/eluser]
It seems as though uri segments without index.php doesn't work correctly, unless I'm doing something wrong.

I load my models based on the uri segment and have removed index.php from the uri. It only works with index.php otherwise it errors out. Any suggestions?

site.com/index.php/view/html/model_name_here

Here is the code from my controller __construct:
Code:
$this->options['uri'] = $this->input->xss_clean($this->uri->uri_to_assoc(4));
$this->options['uri']['controller'] = $this->input->xss_clean($this->uri->segment(1));
$this->options['uri']['action'] = $this->input->xss_clean($this->uri->segment(2));
$this->options['uri']['id'] = @$this->input->xss_clean($this->uri->segment(3));
        
$action = $this->options['uri']['action'];
$model_name =  $this->options['uri']['id'];

$this->load->library('table');    
$this->load->model($model_name);
#2

[eluser]Dennis Rasmussen[/eluser]
What error do you get?
#3

[eluser]Davide Bellini[/eluser]
Have you create .htaccess file??

http://codeigniter.com/wiki/mod_rewrite/
#4

[eluser]Jaketoolson[/eluser]
I'm sorry, I don't get any errors -- it just doesn't load the model_name I need. When I echo out $uri->total_segments() it returns 0, but as soon as I add index.php in the URL, it returns 3.

I'm just trying to use segments without the need of index.php in the url.

I just want to retrieve wants in uri->segment(3) without the need of index.php in the url!!
#5

[eluser]CoolGoose[/eluser]
Did you remove index.php from the config ? (after you added the htaccess rewrite).
#6

[eluser]Jaketoolson[/eluser]
Yes, in my config I have:
Code:
$config['index_page'] = "";

Heres my htaccess file:
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    
    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>
#7

[eluser]Jaketoolson[/eluser]
has anyone else been able to use segments without index.php in the url?
#8

[eluser]Dennis Rasmussen[/eluser]
[quote author="Jaketoolson" date="1289990774"]has anyone else been able to use segments without index.php in the url?[/quote]
We all do Smile
#9

[eluser]Jaketoolson[/eluser]
Well then now I'm really confused why it isn't working for me.

I do use PATH_INFO for my uri_protocol:
Code:
$config['uri_protocol']    = "PATH_INFO";

UPDATE:
I changed this to 'AUTO' and it's working! The original reason I set this to PATH_INFO was because I still needed to pass a lot of $_GET variables through the controllers/models (while maintaining some sort of clean URLS).

i.e.
domain.com/site/html/forward/?hub=32&day=30&time=23

etc.




Theme © iAndrew 2016 - Forum software by © MyBB