Abhijeet Kambli
Abhijeet Kambli

Reputation: 152

cakephp rediect to external url in routes.php

In Cakephp routes.php, How to redirect to external url eg: http://blog.example.com

Router::connect('/blog','http://blog.example.com/');

Upvotes: 0

Views: 1084

Answers (2)

Vivek S
Vivek S

Reputation: 2051

Router::redirect('/blog/*', 'http://blog.example.com', array('status' => 302));

here is the cakephp reference . http://book.cakephp.org/2.0/en/development/routing.html#redirect-routing

Upvotes: 2

chadrien
chadrien

Reputation: 498

This cannot be done with CakePHP. Well actually it could, but you'd better put this in your .htaccess/apache/nginx/whatever server you're using, this is where this kind of thing belongs.

If you really, really, REALLY can't do it that way, you can route /blog to a controller action that will simply redirect.

Config/routes.php
<?php

Router::redirect('/blog/*', 'http://blog.example.com', ['status' => 301]);

Edited with may comment

Upvotes: 2

Related Questions