Reputation: 765
I have four links which I want to redirect to four another domain link. This is the link :
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
I want redirect that links to :
1. https://example2.com/book/ADVVV
2. https://example2.com/book/BNMAF
3. https://example2.com/book/DFTTW
4. https://example2.com/book/DRETT
How to I redirect all that links ? With .htaccess
or anything else ?
Upvotes: 1
Views: 39
Reputation: 1633
You can use this .htaccess
code to redirect given links :
<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>
Upvotes: 1