My cooking site is indexed by a cook search engine as above example
http://mysitename/content.php?r=101-post1%29-test-20%
http://mysitename/content.php?r=102-post1%250-test2-31%
http://mysitename/content.php?r=103-post1%102-test3-40%
etc...
My site has all this posts in the following form:
http://mysitename/post1%29-test-20%
http://mysitename/post2%29-test-20%
http://mysitename/post3%29-test-20%
Is it possible to make a content.php file to redirect all of these references from cook search engine to my site real post?
EDIT: Thank you for your answer but by mistake i forget to mention that me host provider has lightpd server and .htaccess is useless. Any other solution?
EDIT2: I have tested the second option but no luck again. I realised that the problem is the url because the query from search engine is like:
http://mysitename/content.php?r=153-Χημική-δίαιτα-πολλών-κιλών
and it is in greek language
EDIT 3
I test this code:
<?php
header("Status: 301 Moved Permanently");
header("Location:./". $_SERVER['QUERY_STRING']);
exit;
?>
who produce the following result:
http://mysitename/r=153-Χημική-δίαιτα-πολλών-κιλών
is there a way to remove the "r=153-" and leave the rest url "Χημική-δίαιτα-πολλών-κιλών" ? like:
http://mysitename/Χημική-δίαιτα-πολλών-κιλών
That would be a perfect solution. Is it possible?
Save the following as an .htaccess file in root web directory:
Options +FollowSymLinks +Indexes
Order deny,allow
RewriteEngine On
RewriteRule ^([^/]*)$ /content.php?r=$1 [L]
Try this in your .htaccess (at the root):
Options +FollowSymLinks +Indexes
Order deny,allow
RewriteEngine On
RewriteCond %{QUERY_STRING} ^r=([\d]+)-(.*)
RewriteRule ^/?content\.php$ /content/%2 [L,R=301]
This will remove the r=NUMBER-post...
You can test it here http://htaccess.madewithlove.be/