2017-09-14 212 views
1

我有四個鏈接,我想要重定向到另外四個域鏈接。這是鏈接:將多個域鏈接重定向到另一個域鏈接

1. https://example.com/book.php?bid=U0FOMDAwNzQ%2C&&dcode=ADVVV 
2. https://example.com/book.php?bid=U0FOMDAwNzQ%2C&&dcode=BNMAF 
3. https://example.com/book.php?bid=U0FOMDAwNzQ%2C&&dcode=DFTTW 
4. https://example.com/book.php?bid=U0FOMDAwNzQ%2C&&dcode=DRETT 

我想重定向鏈接:

1. https://example2.com/book/ADVVV 
2. https://example2.com/book/BNMAF 
3. https://example2.com/book/DFTTW 
4. https://example2.com/book/DRETT 

如何我重定向所有的鏈接?用.htaccess還是別的?

回答

1

您可以使用此代碼.htaccess重定向給出的鏈接:

<IfModule mod_rewrite.c> 

RewriteEngine On 

RewriteBase/

RewriteCond %{HTTP_HOST} ^domain.com$ [NC] 
RewriteCond %{REQUEST_URI} ^/book.php$ [NC] 
RewriteCond %{QUERY_STRING} ^bid=U0FOMDAwNzQ%2C&&dcode=([A-Z]+)$ [NC] 
RewriteRule ^(.*)$ https://example2.com/book/%1 [R=301,L,QSD] 

</IfModule> 
相關問題