如何使cakephp 3 URL准备好进行市场营销? [英] How to make cakephp 3 url ready for marketing?

查看:50
本文介绍了如何使cakephp 3 URL准备好进行市场营销?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Cakephp的新手.我正在尝试重写网址以使其对SEO友好.

我在Cakephp3中为cms页面创建了模块.

页面表-网址字段想用作关于我们"

 如果不存在`pages`,则创建表(`id` int(11)NOT NULL,`title` varchar(100)NOT NULL,`detail`文字NOT NULL,url varchar(225)NOT NULL,)ENGINE = InnoDB AUTO_INCREMENT = 14 DEFAULT CHARSET = latin1; 

当前网址(有效)-

打开"routes.php"并使用:

 使用Cake \ Routing \ Router;//使用作用域路由生成器.Router :: scope('/',function($ routes){$ routes-> connect('/about-us',['controller'=>'Pages','action'=>'view',8]);});//或使用静态方法.Router :: connect('/about-us',['controller'=>'Pages','action'=>'view',8]); 

I am new for cakephp. I am trying to rewrite the url to make it SEO friendly.

I have create module in cakephp3 for cms page.

Page Table - url field would like to use as "about-us"

CREATE TABLE IF NOT EXISTS `pages` (
  `id` int(11) NOT NULL,
  `title` varchar(100) NOT NULL,
  `detail` text NOT NULL,
  `url` varchar(225) NOT NULL,
) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=latin1;

Current URL (working)- https://example.com/pages/view/8

I want to make this like below. https://example.com/about-us

Please suggest.

解决方案

In your cakephp3 folder, there is a file "routes.php" in \config.

Open the "routes.php" and use:

use Cake\Routing\Router;

// Using the scoped route builder.
Router::scope('/', function ($routes) {
    $routes->connect('/about-us', ['controller' => 'Pages', 'action' => 'view', 8]);
});

// Or using the static method.
Router::connect('/about-us', ['controller' => 'Pages', 'action' => 'view', 8]);

这篇关于如何使cakephp 3 URL准备好进行市场营销?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆