2012-11-29 54 views
0

我剛剛將一個很早以前寫入的網站遷移到wordpress。根據傳入的URL重定向

這樣做會導致url結構與現在使用mod-rewrite不同。我意識到,在我投入新網站之後,有些電子郵件已發送給客戶,使用舊網址從網站兌換禮券。

我的問題是,與htaccess有一個URL重定向,我可以做,並保持獲取信息。例如,我需要這個網址:

www.test.com/redeem.php?id=123

重定向到:

www.test.com/redeem/now/?id=123

如果有與.htaccess無解,沒有任何人有任何PHP解決?

這裏是我的htaccess的文件看起來像現在:

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/
    RewriteRule ^index\.php$ - [L] 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule . /index.php [L] 
    </IfModule> 

感謝您的幫助。

回答

0

我最終什麼事做的是寫在頭文件中的代碼和它的作品。

<?php 
    if (array_shift(explode('?', $_SERVER['REQUEST_URI'])) == "/redeem.php") { 
     header ('Location: /gift-certificates/redeem/?id=' . $_GET["id"]); 
    }?> 
0

是否會像你想

http://test.com/redeem/now/read/2 

中的.htaccess

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 
# END WordPress 

using permalink wordpress

+0

感謝您的回覆,但看起來和我已經完全一樣。我想將網址轉發或重定向到wordpress爲結構選擇的其他網址。 – tecshaun