EronarDiaras
EronarDiaras

Reputation: 87

How could I redirect an url with routes.php or htaccess?

How could I redirect an url with routes.php or htaccess?

My homepage:

teszt.hu/onecontroller/oneaction/
teszt.hu/categories/index/

And the redirect:

teszt.hu/specword/categories/index/ => teszt.hu/categories/index/?s=specword
teszt.hu/specword/onecontroller/oneaction/ => teszt.hu/onecontroller/oneaction/?s=specword

Upvotes: 1

Views: 158

Answers (2)

EronarDiaras
EronarDiaras

Reputation: 87

$accWebpages = '(webpage1|webpage2|specword)';

//Router::connect('/:accwebpage/:controller/:action', array(), array('pass' => array('accwebpage'), 'accwebpage' => $accWebpages));

Router::connect('/:accwebpage/', array('controller' => 'homes', 'action' => 'index'), array('pass' => array('accwebpage'), 'accwebpage' => $accWebpages));

Router::connect('/kategoria/:page/:category-:slug', array('controller' => 'products', 'action' => 'index'), array('pass'=>array('page', 'category', 'slug'), 'page' => '[0-9]+', 'category' => '[0-9]+'));
Router::connect('/:accwebpage/kategoria/:page/:category-:slug', array('controller' => 'products', 'action' => 'index'), array('pass'=>array('page', 'category', 'slug', 'accwebpage'), 'page' => '[0-9]+', 'category' => '[0-9]+', 'accwebpage' => $accWebpages));
...

Upvotes: 0

Dave
Dave

Reputation: 29121

You should use CakePHP's Routes for this.

Read more about routes here: http://book.cakephp.org/2.0/en/development/routing.html

Off the top of my head, I think it would be something like this:

Router::connect(
    '/specword/:controller/:action',
    array('?' => array('s'=>'specword')),
);

Upvotes: 3

Related Questions