CodeIgniter Forums
Clean URL - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Clean URL (/showthread.php?tid=38627)



Clean URL - El Forum - 02-14-2011

[eluser]Pellens[/eluser]
Hi webmasters,

I have a website using the following URL:
http://www.reisgoedkoop.com/index/lijst/type/zomervakantie/agent/-/land/-/prijs_min/-/prijs_max/-

I would like to make it shorter, is it possible to hide the controller index and function lijst? Like following:
http://www.reisgoedkoop.com/type/zomervakantie/agent/-/land/-/prijs_min/-/prijs_max/- or even
http://www.reisgoedkoop.com/zomervakantie/agent/-/land/-/prijs_min/-/prijs_max/-

I've tried some routing, as well .htaccess but I'm not able to make it work,
also I don't know if it's possible of course...

Thank you very much in advance,
Pellens


Clean URL - El Forum - 02-14-2011

[eluser]crnalajna[/eluser]
in your /application/config/routes.php
Code:
$route['zomervakantie/(:any)'] = 'lijst/type/zomervakantie/$1';


put .htaccess in website root
Code:
<IfModule mod_rewrite.c>

    Options +FollowSymLinks
    RewriteEngine on

    # NOTICE: If you get a 404 play with combinations of the following commented out lines
    #AllowOverride All
    #RewriteBase /cms

    # Send request via index.php (again, not if its a real file or folder)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    <IfModule mod_php5.c>
        RewriteRule ^(.*)$ index.php/$1 [L]
    </IfModule>

    <IfModule !mod_php5.c>
        RewriteRule ^(.*)$ index.php?/$1 [L]
    </IfModule>

</IfModule>



Clean URL - El Forum - 02-14-2011

[eluser]Pellens[/eluser]
Thank you very much! It's is working.

One question:
I see that the
Code:
$this->uri->uri_to_assoc()
is not working anymore,
is this normal? It's not a problem, I made a work around, but just to know...

Greetings!


Clean URL - El Forum - 02-14-2011

[eluser]crnalajna[/eluser]
It's normal.
You need to use ruri_to_assoc() instead of uri_to_assoc() after routing.


Clean URL - El Forum - 02-14-2011

[eluser]Pellens[/eluser]
Thank you very much!
Learned something new again, nice.