0

I've discovered an odd problem. I run website.com. (for this example)

If I visit website.com/play, all my links are just fine. If I visit website.com/play/ or play/index, all the links suddenly break.

I build all my URLs using this->Html->url(array('controller' => 'whatever', 'action' => 'whatever'));

I'm wondering how I could make it so that someone could visit website.com/play/ or website.com/play/index and have it forwarded over to website.com/play. This should be without javascript. I can't seem to figure out if CakePHP's routing does this, but I'm nearly certain it does.

Writing Router::connect('/play/', array('controller' => 'plays')); did not help.

UPDATE

Looking around the internet, I found it suggested for CakePHP to simply reroute with .htaccess. This answer:

RewriteRule ^(.*)/$ $1 [R=301,L]

Worked just fine.

Community
  • 1
  • 1
Vael Victus
  • 3,966
  • 7
  • 34
  • 55

1 Answers1

1
  • The better way is to have the links checked out.
  • Is the controller called Play or Plays? Are you accessing /play or /plays?
  • Are you creating links this way? echo $this->Html->link('Add User', array('controller' => 'Users', 'action' => 'add'));
  • Can you paste an example of an incorrect link you get on /play/, and how it was created?
cornelb
  • 6,046
  • 3
  • 19
  • 30
  • The links are all built with $this->Html->url() and the controller is plays, with a route I created for "/play". I updated my question with my solution. Thanks. – Vael Victus Jan 24 '14 at 19:34