duan2428 2015-06-27 17:04
浏览 52
已采纳

将旧网址重定向到新网址[codeigniter .htaccess]

My old website had trouble so I code a new one. But I cant redirect my old URL to new URL. My old URL looks like :

http://sample.com/?m=news&e=view&id=66

It already shared and SEO on google. But I completed remove old source in my host. I want when someone click in that link, it will redirect to my new page:

http://sample.com/en/news/redirect-url-66.html

But idk how to write Rule for htaccess.Can anyone tell me what should I do. This's my htaccess (default CodeIgniter htaccess):

RewriteEngine on 
RewriteCond $1 !^(index\.php|resources|robots\.txt) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L,QSA]  
  • 写回答

2条回答 默认 最新

  • dqypcghd381390 2015-06-27 20:05
    关注

    old url:

    http://sample.com/?m=news&e=view&id=66
    

    new url:

    http://sample.com/index.php/en/news/redirect-url-66.html 
    

    .htaccess

    RewriteEngine on 
    RewriteCond $1 !^(index\.php|resources|robots\.txt) 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]
    
    RewriteCond  %{QUERY_STRING} m=([a-z]+) $1
    RewriteCond  %{QUERY_STRING} e=(view) $2
    RewriteCond  %{QUERY_STRING} id=([0-9]+) $3 
    RewriteRule ^(.*)$ index.php/en/%1/redirect-url-%3.html?
    

    Hope that works for you

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码