我有一个房地产网站,在笨我的链接名称是:笨更改URL路由
htp://examplesite(dot)com/property/31/en/property_title
我想取代它:
htp://examplesite(dot)com/my-custom-slug.htm
或
htp://examplesite(dot)com/property_title
两种方式都可以。我的路线是:
$route['default_controller'] = "frontend";
$route['404_override'] = 'frontend';
/* Custom routing */
$route['admin'] = 'admin/dashboard';
//$route['secret'] = 'admin/dashboard';
// To change property->listing in uri
$route['listing/(:num)/(:any)/(:any)'] = "property/$1/$2/$3";
$route['listing/(:num)/(:any)'] = "property/$1/$2";
这种情况下最好的方法是什么?
我知道有一个可能的解决方案是:
添加
$配置[ 'listing_uri'] = '上市';
不是增加:
在 '应用程序\设置\ routes.php文件'
后:
$route['listing/(:num)/(:any)/(:any)'] = "property/$1/$2/$3";
$route['listing/(:num)/(:any)'] = "property/$1/$2";
添加也:
$route['changed/(:num)/(:any)/(:any)'] = "property/$1/$2/$3";
$route['changed/(:num)/(:any)'] = "property/$1/$2";
,但有什么办法删除'上市',只看到干净的网址(为了更好的SEO目的)??
我只是写了同样的东西,但后来你发布在我面前:-) – cartalot
我知道有一个解决方案来添加:$ config ['listing_uri'] ='listing';比添加$ route ['changed /(:num)/(:any)/(:any)'] =“property/$ 1/$ 2/$ 3”; $ route ['changed /(:num)/(:any)'] =“property/$ 1/$ 2”;但我想删除列表,并只看到examplesite(dot)com/custom_slug.htm有没有什么办法? – Fuente
我不确定我是否理解你的意思,你能否详细说明一下?您可以使用上面提到的解决方案而不使用列表部分,如果您有任何其他特定路由,只需在配置文件的此路由之前添加它即可,因为codeigniter会自上而下地解释它。这个问题是你假设你的域名是一个有效的上市后,所以你的验证只需要声音,并显示404,如果上市不存在 – peanut