Reputation: 11
I have a particular scenario: the old site urls were made this way: http://www.mysite.it/it/my-old-link
The new one are made this way: http://www.mysite.it/vini.php?famiglia=my-new-link
I would like to the link http://www.mysite.it/it/my-old-link
to point to http://www.mysite.it/vini.php?famiglia=my-new-link
This is to preserve SEO position. So, when someone click on search result http://www.mysite.it/it/my-old-link will be redirected
to http://www.mysite.it/vini.php?famiglia=my-new-link
But I cannot find a way to do this editing the .htaccess file.
I've set a rewrite rule and a redirect but it doesn't work; here an example of the .htaccess file:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteBase /
RewriteRule ^/?([^/d]+)/?$ /vini.php?famiglia=$1 [L,QSA]
Redirect 302 http://www.mysite.it/it/my-old-link http://www.mysite.it/my-new-link
ErrorDocument 404 http://www.mysite.it/index.php
But it doesn't work: if I enter http://www.mysite.it/it/my-old-link
in the browser I get the 404 page error (index.php)
However: if I enter http://www.mysite.it/my-new-link
on the browser I get the correct page.
Is there a way to solve this problem?
TIA tony
Upvotes: 1
Views: 351
Reputation: 133428
In case you are looking for specific rule as per shown samples then try following.
RewriteEngine ON
RewriteRule ^it/my-old-link/?$ vini.php?famiglia=my-new-link [NC,L]
In case you are looking for Generic rules, where if a URI is NOT present as a file or directory then try following. Please make sure either you put above or following rules only at a time.
RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ vini.php?famiglia=my-new-link [NC,L]
Upvotes: 1