droe9376 2014-12-22 12:42
浏览 66

使用codeigniter中的路由功能重定向url

I have local site and in that site I have integrated 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

1) When I use:

  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? 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/
  • 写回答

1条回答 默认 最新

  • duandie5707 2014-12-22 12:47
    关注

    You can use that in root .htaccess:

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

报告相同问题?

悬赏问题

  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?
  • ¥100 求三轴之间相互配合画圆以及直线的算法
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败