I want to redirect the home of my old site to the home of my new site, while I want every subpage to redirect to the page search of the new site.
Briefly:
www.oldsite.it –> http://newsite.it
and
www.oldsite.it/whatever –> http://newsite.it/search?q=whatever
I want the conditions to live both and strictly.
I achieved to let them work but separately.
Here’s my code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} oldsite.it/$
RewriteRule ^(.*)$ http://newsite.it/search?q=$1 [R=301,L]
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
How can I make them work?
Thanks
You need 2 conditional rules here to redirect the old homepage and old urls to the new location ,try :
Clear your browser’s cache before testing these rules.
To make the redirect permanent ,change R to R=301 in both rules when you are sure the rules are working.