简体   繁体   English

使用codeigniter中的route函数重定向url

[英]redirect url using route function in codeigniter

I have local site and in that site I have integrated wordpress + codeigniter. 我有一个本地站点,在那个站点中我集成了wordpress + codeigniter。

Now I have a blog and custom query to fetch posts from wordpress database using wordpress wp_query function, everything is working pagination is also working but I'm having a small issue that if I type my blog address without a trailing / than the pagination doesn't work properly 现在,我有一个博客和自定义查询,可以使用wordpress wp_query函数从wordpress数据库中获取帖子,一切正常,分页功能也可以正常工作,但是我有一个小问题,如果我键入我的博客地址时没有尾随/不是分页功能不一样,不能正常工作

1) When I use: 1)当我使用:

  siteaddress/blog/

it works just fine and pagination also work like: 它可以正常工作,分页也可以像:

  siteaddress/blog/page/1
  siteaddress/blog/page/2

I can move forward and backward properly 我可以正确地前进和后退

Only problem came when I open url 打开网址时唯一的问题出现了

 siteaddress/blog

than the pagination url becomes 分页网址变成

siteaddress/blogpage/1
siteaddress/blogpage/2

It means missing 1 trailing / between blog and page so can I solve this issue using codeigntiers route? 这意味着在博客和页面之间缺少1个尾随/ ,所以我可以使用codeigntiers路由解决此问题吗? I already tried: 我已经尝试过:

$route['blog'] = "blog/page/$1";

and

$route['blog'] = "blog/";

these both methods couldn't solve my problem. 这两种方法都无法解决我的问题。

Any help will be appreciated. 任何帮助将不胜感激。

live version for my site is: 我的网站的实时版本为:

aws.chemfreecom.com/blog  or aws.chemfreecom.com/blog/

You can use that in root .htaccess : 您可以在根.htaccess使用它:

RewriteEngine on 
RewriteRule ^blog$ blog/ [R=301,NC,L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM