drd0833 2014-05-04 14:06 采纳率: 100%
浏览 60
已采纳

如何编写htaccess来重定向我的网站?

sorry for my poor english.

I use SMF to running my forum.

This is old forum URL => hxxp://www.mysite.com/

But now, I move my forum to "forum" folder => hxxp://www.mysite.com/forum/

Google and other search engine indexed my site with url: hxxp://www.mysite.com/index.php?topic=99.0

And when users go to hxxp://www.mysite.com/index.php?topic=99.0, It's not found.

Because he must to go to hxxp://www.mysite.com/forum/index.php?topic=99.0, right?

So, I want to redirect url from hxxp://www.mysite.com/index.php?topic=99.0 to hxxp://www.mysite.com/forum/index.php?topic=99.0

How should I do? I try this but not work.

RewriteEngine On
RewriteBase /
RewriteRule ^index.php?topic=([0-9]+).([0-9]+)$ forum/index.php?topic=$1.$2 [R]

Help me please.

  • 写回答

3条回答 默认 最新

  • dongquexi1990 2014-05-04 17:54
    关注

    depends on where you put htaccess. If it is in /forum/ then

    RewriteCond %{REQUEST_URI} !^\/forum\/
    RewriteRule ^index\.php$ http://%{HTTP_HOST}/forum/index.php [R]
    

    AFAIK query string is not affected by RewriteRule regexp. http://httpd.apache.org/docs/2.4/mod/mod_rewrite.html

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

报告相同问题?

悬赏问题

  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler