Welcome Guest, Not a member yet? Register   Sign In
Solved: Redirect all URL segments to controller
#1

[eluser]kirkaracha[/eluser]
I need to route all URL segments on my domain to my default controller, with the first URL segment being a variable that gets passed to my controller. For example: example.com/something would be passed to my default controller with "something" passed as a variable.

I have this in routes.php:

Code:
$route['(:any)'] = 'default/$1/';
$route['default_controller'] = 'default';

And here's my .htaccess (I'm on Dreamhost):

Code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>

If I go to example.com/something I get CodeIgniter's 404 message.




Theme © iAndrew 2016 - Forum software by © MyBB