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 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题