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条)

报告相同问题?