我有四个链接,我想重定向到另外四个域链接。这是链接:
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
还是其他什么?
答案 0 :(得分: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>