Wednesday, October 17, 2012

Re: how can i route /size to /size.html

Modifying .htaccess almost renders the solution "outside of CakePHP" scope, doesn't it?

A 301 permanently redirects to size.html, I'm guessing Murray is trying to have a pretty URL, so this should do it:

    #add this line above Cake's rewrites in app/webroot/.htaccess
    RewriteRule ^size$ size.html

    #Cake's rewrites...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php [QSA,L]

Otherwise just leave it as-is and use /size.html

On Thursday, October 18, 2012 5:45:00 AM UTC+2, ibejohn818 wrote:
Mod Rewrite /size to 301 to size.html
No need to be hosting duplicate content.

On Oct 17, 2012, at 8:42 PM, Vanja Dizdarević <lex.non...@gmail.com> wrote:

+1 on that.

An example:

Move it from app/webroot/size.html to app/View/Pages/size.ctp
Add Router::connect('/size', array('controller'=>'pages', 'action'=>'display', 'size')); to the routes.php
This would of course render this page inside your default layout, which might not be what your are trying to achieve.

A way around that is to add an action to the PagesController:
Move from app/webroot/size.html to app/View/Pages/size.ctp
Add Router::connect('/size', array('controller'=>'pages', 'action'=>'size')); to the routes.php
In your PagesControler create a function:
public function size(){
$this->layout = 'empty';
}
create an empty layout:
//app/View/Layouts/empty.ctp
<?php echo $this->fetch('content'); ?>

(or divide your file into layout + content)

This way you avoid creating a new random controller to, basically, serve a single static page.



On Thursday, October 18, 2012 5:09:28 AM UTC+2, thatsgreat2345 wrote:
You should NOT be doing this. If you want to, then create a controller, and a view then you can use cakephp routes to route the way you want it to.

On Wednesday, October 17, 2012 7:20:55 PM UTC-7, Murray wrote:
I just have a static html file which is app/webroot/size.html. I can access it by the url "/size.html".
But how can i route /size to /size.html?

--
Rui WANG(王瑞)
Murray
School of Electronics Engineering and Computer Science,
Peking University

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake...@googlegroups.com.
To unsubscribe from this group, send email to cake-php+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: