【问题标题】:Codeigniter routes & .htaccess permanent removeCodeigniter 路由和 .htaccess 永久删除
【发布时间】:2017-01-08 16:44:15
【问题描述】:

我正在升级我的系统并在 Codeigniter 中构建它。

我现在需要重写旧网站 URL 以重定向到新的系统 URL 结构。

旧网址如下所示:

http://www.domain.com/top-category/two-subcategory/2-13-123453/title.html

新的 URL 将类似于:

http://www.domain.com/advertise/2-13-123453/title.html

我在 .htaccess 文件中尝试了以下操作,但没有成功:

RewriteRule ^([a-z-]+)/([a-z-]+)/([0-9-]+)/([A-Za-z0-9-]+)$ /advertise/$3/$4 [L,R=301]

然后我尝试查看是否可以使用 Ci 路由文件修复它,但没有成功:

$route['(:any)/(:any)/(:num)/(:any)'] = "advertise/index/$3/$4";

不知道我还应该尝试什么或我做错了什么。

【问题讨论】:

    标签: php .htaccess codeigniter mod-rewrite


    【解决方案1】:

    我最终在 RewriteBase / 之后使用了以下代码

    RewriteRule ^([A-Za-z-]+)/([A-Za-z-]+)/([A-Za-z-]+)/([A-Za-z-]+)/([0-9-]+)/(.*)$ /advertise/$5/$6 [L,R=301]
    RewriteRule ^([A-Za-z-]+)/([A-Za-z-]+)/([A-Za-z-]+)/([A-Za-z-]+)/([0-9-]+)$ /advertise/$5 [L,R=301]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-10-07
      • 2013-06-19
      • 2018-04-23
      • 2019-06-18
      • 2012-08-15
      • 2016-11-03
      • 2013-10-15
      相关资源
      最近更新 更多