2014-05-04 23 views
1

對不起我的英文不好。如何編寫htaccess重定向我的網站?

我使用SMF來運行我的論壇。

這是老論壇URL =>hxxp://www.mysite.com/

但現在,我將我的論壇, 「論壇」 文件夾=>hxxp://www.mysite。 COM /論壇/

谷歌等搜索引擎收錄我的網站網址:hxxp://www.mysite.com/index.php話題= 99.0

而當用戶去hxxp ://www.mysite.com/index.php?topic = 99.0,找不到。

因爲他必須去hxxp://www.mysite.com/forum/index.php?topic = 99.0,對吧?

所以,我想從hxxp重定向URL ://www.mysite.com/index.php話題= 99.0hxxp://www.mysite.com/forum/index.php ?topic = 99.0

我該怎麼辦?我嘗試這個,但不工作。

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

請幫助我。

+0

嘗試'^/index.php'而不是'^ index.php' – Zaffy

回答

0

我猜你一定逃脫點(.)元字符在重寫規則:

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

謝謝,但我嘗試不起作用。 T_T – user3601462

0

我希望這將幫助ü

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} -f [OR] 
RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule .+ - [L] 
RewriteRule ^index.php?topic([=0-9.]+)$ old/index.php?topic=$1 [QSA,L] 
+0

謝謝,但我嘗試不起作用。 T_T – user3601462