• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
routes not working

#1
[eluser]learning_php[/eluser]
Hi,

I have set the following routes:
Code:
$route['default_controller'] = "homepage";
$route[''] = "index.php/homepage";


$route['info'] = 'index.php/homepage/Info';
$route['Gifts'] = 'index.php/homepage/Gifts';
$route['gallery'] = "index.php/gallery";
$route['register'] = "index.php/homepage/register";
$route['Church'] = "index.php/direction/direction";
$route['JockeyClub'] = "index.php/direction1/direction1";
$route['images'] = "index.php/Dashboard/index";
$route['scaffolding_trigger'] = " ";

but they dont seem to be working on my site www.wesayido.co.uk

Thanks

#2
[eluser]Dam1an[/eluser]
You don't need the index.php in the re routed path, just the controller, method and args

#3
[eluser]learning_php[/eluser]
Hi,

i changed the routes to this:
Code:
$route['default_controller'] = "homepage";
$route[''] = "homepage";


$route['info'] = 'homepage/Info';
$route['Gifts'] = 'homepage/Gifts';
$route['gallery'] = "gallery/index";
$route['register'] = "homepage/register";
$route['Church'] = "direction/direction";
$route['JockeyClub'] = "direction1/direction1";
$route['images'] = "Dashboard/index";
$route['scaffolding_trigger'] = " ";

and link to it like this:
Code:
<li><a href='homepage/index'>Homepage</a></li>

but when i click the live link it takes me to this
Code:
http://www.wesayido.co.uk/index.php/gallery/homepage/index

but the generated code displays this:
Code:
<li><a href='homepage/index'>Homepage</a></li>

#4
[eluser]Dam1an[/eluser]
you have the index_page in the config set to index.php? as anchors are made up of your base url, index page, and the target

#5
[eluser]learning_php[/eluser]
hi,

i looked in the cofig file and it like this
Code:
$config['index_page'] = "";
but none of my links work unless they are declared like
Code:
<li><a href='index.php'>Homepage</a></li>

#6
[eluser]Dam1an[/eluser]
Do you have your htaccess to rewrite the index.php into the URL?
Here's mine
Code:
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]

#7
[eluser]learning_php[/eluser]
Hi,

This is my .htaccess file
Code:
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$./index.php/$1 [QSA,NC,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.

  ErrorDocument 404 /index.php
</IfModule>

and my routes are now:
Code:
$route['default_controller'] = "homepage";
$route[''] = "homepage";


$route['info'] = 'homepage/Info';
$route['Gifts'] = 'homepage/Gifts';
$route['gallery'] = "gallery/index";
$route['register'] = "homepage/register";
$route['Church'] = "direction/direction";
$route['JockeyClub'] = "direction1/direction1";
$route['images'] = "Dashboard/index";
$route['scaffolding_trigger'] = " ";

and i am linking to the pages like:
Code:
<li><a href=''>Homepage</a></li>
    <li><a href='homepage/Info'>Information</a></li>
    <li><a href='homepage/Gifts'>Gifts</a></li>
    <li><a href='gallery/index'>Gallery</a></li>

and i get a 404 error????

#8
[eluser]Thorpe Obazee[/eluser]
I don't know if I get it but don't you need to have

Code:
echo anchor('info');

to get to homepage/info?

then

Code:
echo anchor('gifts');

to get to homepage/gifts?

The routing is quite weird. It's like you're doing routing the other way around.

#9
[eluser]xwero[/eluser]
if you use links to the right controller and method why do you need to use routes?

#10
[eluser]learning_php[/eluser]
Hi

I changed my links to this:
Code:
<li>&lt;?= anchor('','Homepage');?&gt;</li>
    <li>&lt;?= anchor('Info','Information');?&gt;</li>

the homepage one refreshes the home page but on the Info i still get a 404?


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.