Welcome Guest, Not a member yet? Register   Sign In
problem with URL on main page
#1

[eluser]smck87[/eluser]
Hello,
when i open main page of my site using for example this url:
http://mywebsite.com

main page loads and i get this in address bar:
http://mywebsite.com/controller-name/action-name

but i need just http://mywebsite.com on my main page
How can i do this?
#2

[eluser]pickupman[/eluser]
This should happen by default. Are you using a redirect somewhere? Got some code to post for us to take a look at.
#3

[eluser]smck87[/eluser]
Yes, this happens by default, but i want to get just address of website on my main page without additional 'controller/index'. My code is usual, nothing special, no redirects:
Code:
class Main extends Controller {
    function Main()
    {
        parent::Controller();
    }

    function index()
    {
        $this->load->view('index_view');
    }    
}
#4

[eluser]pickupman[/eluser]
No, I meant when someone types in your domain http://example.com should not be changing to http://example.com/controller/index. It should just stay as http://example.com. Are you using .htaccess somewhere that could cause this?

This should even happen when someone types in http://example.com/main. It should stay that way and load the index method since the 2nd segment is omitted.
#5

[eluser]mi6crazyheart[/eluser]
[quote author="smck87" date="1281866737"]Yes, this happens by default, but i want to get just address of website on my main page without additional 'controller/index'. My code is usual, nothing special, no redirects:
Code:
class Main extends Controller {
    function Main()
    {
        parent::Controller();
    }

    function index()
    {
        $this->load->view('index_view');
    }    
}
[/quote]

Hey!!!, i think u might've done some changes in u'r .htaccess file or in config.php file due to which it might have redirecting to "main.php" controller file rather than "Welcome.php" which is the default one...
#6

[eluser]smck87[/eluser]
Yes, i have changed application\config\routes.php
$route['default_controller'] = "main/index";
#7

[eluser]mi6crazyheart[/eluser]
[quote author="smck87" date="1281831892"]Hello,
when i open main page of my site using for example this url:
http://mywebsite.com

main page loads and i get this in address bar:
http://mywebsite.com/controller-name/action-name

but i need just http://mywebsite.com on my main page
How can i do this?[/quote]

if u need this then, is their any particular reason to make that changes in that "routes.php" file ? Because, without doing that changes also u can u can achieve what u've asked for by just : remove the changes which u've done in that "routes.php" file & open u'r VIEW folder and make necessary changes in that "welcome_message.php" file. Else, u can create a another view file & load that view file from u'r "welcome.php" controller...
#8

[eluser]smck87[/eluser]
Thanks a lot! It works :ahhh:
#9

[eluser]pickupman[/eluser]
The default controller should be simply
Code:
$route['default_controller'] = 'main';


Glad you got it figured out.
#10

[eluser]smck87[/eluser]
[quote author="pickupman" date="1281980037"]The default controller should be simply
Code:
$route['default_controller'] = 'main';
[/quote]
Yes, right, but it produces 'main/index' in address bar, so seems like only $route['default_controller'] = 'welcome' works fine :-S




Theme © iAndrew 2016 - Forum software by © MyBB