Welcome Guest, Not a member yet? Register   Sign In
How to change url from www.url.com/site/aboutus to url.com/aboutus
#1

[eluser]NyiPHP[/eluser]
Hello, im new to codeigniter and i have a few questions.

At the moment my website url looks like.

http://sub.domain.com

my default controller is site.
Code:
$route['default_controller'] = "site";

i am using autocrum from the forum
http://ellislab.com/forums/viewthread/137949/

when i go to about the url will be
http://sub.domain.com/site/about
and the breadcrum looks like
Home > Site > About

i want the url to be
http://sub.domain.com/about
which probably will make the crum look like
Home > About

my .htaccess file looks
Code:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
#2

[eluser]jairoh_[/eluser]
if the 'about' is a function of the controller site, then i don't think it's possible. unless it's another controller.
#3

[eluser]TheFuzzy0ne[/eluser]
You can use a route: http://ellislab.com/codeigniter/user-gui...uting.html
#4

[eluser]NyiPHP[/eluser]
aha, so i will have to make a controller for each. tyvm got it.

like.
controller/site.php = main/index file
controller/about.php = about

url ->
url.com or url.com/site or url.com/site/home
url.com/about

is this a more correct solution?
#5

[eluser]TheFuzzy0ne[/eluser]
The route for your "about" page, would probably be something like this:

Code:
$route['about'] = 'site/about';

No need to create extra controllers. The whole point of routing is that you can pretend that one URL is actually another, and transparently map a make-believe URL to an existing controller method.

Code:
$route['look/ma/a/non/existent/url'] = 'site/about';

The downside is that the site/about URL will still also work, but the page is still accessible the way you want. Smile
#6

[eluser]CroNiX[/eluser]
I think the problem is with that autocrumb library you are using, although I haven't looked at its code. It might not recognize the routes and put the full "crumb" instead of the "routed" crumb, which is probably what it's doing for your default controller (which technically is a route). You might just create your own crumbs instead of an autogenerating library. That's one of the things I pass to my template library when generating a view. You'll have more control.




Theme © iAndrew 2016 - Forum software by © MyBB