I have a new question related to this question, but since the questions do not match at all, I am creating this new topic. But it is for good reference.
I changed my mind about the logs
to log
thing, logs
is fine. But I am having another controller called WikisController
, in this case I would really like to change the URL. I just hate it that the URL will be example.com/wikis/subject.html
, I want it to be example.com/wiki/subject.html
. It is much cleaner and the convention is now a 100% match with other sites where it is also called wiki
, and not wikis
. But, I want the controller to be called WikisController
, because of the CakePHP
convention.
Well, now comes the real problem. I was currently using the following routing in Config/routes.php
:
Router::connect('/wiki/:action/*', array('controller' => 'wikis'));
Router::connect('/wiki/*', array('controller' => 'wikis'));
This is the piece of code used by the solution in the other topic. But now I am running into a little bit of trouble. Well, it isn't really a big issue because everything works just fine. But I don't like the URL.
When I create a link as the following from example.com/wiki/edit.html
:
echo $this->Html->link('Wiki overview', array(
'controller' => 'wikis',
'action' => 'index',
'ext' => 'html'
));
It is creating a link to example.com/wiki/index.html
totally fine and it works, but I don't want to show the index.html
, I just don't. It is a word extra in the url and it is not necessary for the user to understand where he is.
I am creating the link
with the controller
and action
key because of a little bug I was having earlier. When I didn't specify the action
, it would create a link to example.com/edit.html
which I don't want, obviously. So I have to add the action => index
key to the array. I am not sure if this is a real bug, but it shouldn't matter. Index = index
and nothing changes that. It is a good thing that I am sure my URL is pointing to the right page, so adding the action
isn't an issue for me.
Just for good notice:
When I am creating a link on exactly the same way as I did above to example.com/flights/index.html
from the page example.com/flights/add.html
it would delete the /index
part from the url and simply create a url to example.com/flights.html
which is much cleaner.
So it has to do something with the routing, but I can't figure out what.