Forum Moderators: phranque
This is to difficult for me so i would appreciate some help..
Imagine having a lot of forum urls in google and then you decide to switch forum.
Big problem..
So my situation is as follows...
the old forum is is like this: website.com/image-vp0123456.html
So the image-vp0123456.html is the url
What lines could i use to redirect every google request (people coming from google search) to /forum ?
Any help please ?
Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{HTTP_REFERER} google\.com
RewriteCond %{REQUEST_URI} !^/forum/
RewriteRule .* http://www.example.com/forum/ [R=301,L]
See the references cited in our forum charter for more information.
Jim
[edited by: jdMorgan at 12:10 pm (utc) on Nov. 4, 2008]
the old forum is is like this: website.com/image-vp0123456.html
So the image-vp0123456.html is the url
i dont see any code that rewrites all image-vp0123456.html etc..-> to /forum/
i mean...in google it has thousands of links like...
http://forum.example.com/image-vp0123456.html
there are thousands of different numbered html files,so the code to rewrite should recognize it as $1,2,3,4,5,6,k7,8,9,0 etc...
[edited by: jdMorgan at 3:32 pm (utc) on Nov. 4, 2008]
[edit reason] Please use example.com only. [/edit]
It is not likely that any code I post will be perfect for you, which is why you must attain the ability to understand and modify the code yourself. Otherwise, you will depend on others for the maintenance, well-being, and search rankings of your site. Unless you have a trusted part-time contractor on-call for this purpose, that is a really bad idea. It would be better to just let Google re-spider the site and put up with the 404s for awhile than to put code on your server that you don't understand.
Please read very, very carefully: Am I to understand that you wish to redirect only URLs of the form "http://forum.example.com/image-vp<seven-digit-number>.html", and that all of those those URLs are to be redirected to "http://www.example.com/forum/" or do you want something else?
Jim
Options +FollowSymLinks
RewriteEngine on
#
# If request referred from google.com domain (or any google subdomain)
RewriteCond %{HTTP_REFERER} ^https?://([^./]+\.)*google\.com
# and if our forum subdomain requested
RewriteCond %{HTTP_HOST} ^forum\.example\.com
# Externally redirect requests for /image-vp<six digits>.html to /forum/ index on main domain
RewriteRule ^image-vp[0-9]{6}\.html$ http://www.example.com/forum/ [R=301,L]
It will not redirect Googlebot or user-type-ins of the old URLs, because these requests will not include an HTTP Referer header. If you wish the rule to be applied to these cases, then delete the first RewriteCond.
It will not redirect requests for any other subdomains, or for URL-paths which do not match the "image-vp<six digits>.html" pattern.
Be sure to completely-flush your browser cache before testing.
Jim