homepage Welcome to WebmasterWorld Guest from 107.22.37.143
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Accredited PayPal World Seller

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
Howto rewrite google request old to new forum url ?
john1000




msg:3777824
 9:58 pm on Oct 31, 2008 (gmt 0)

Hello,

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 ?

 

jdMorgan




msg:3777837
 10:19 pm on Oct 31, 2008 (gmt 0)

See Apache mod_alias or mod_rewrite. We can take specific questions, but this is a discussion forum, and we cannot write your code for you. There are not enough contributors here to offer that level of service. :(

Jim

john1000




msg:3777853
 10:30 pm on Oct 31, 2008 (gmt 0)

yes i understand....
but if i was capable of learning this i would do it.
some people never learn ,and its not my fault im one of them.

john1000




msg:3778449
 1:36 am on Nov 2, 2008 (gmt 0)

C'mon ...anybody ?
Is nobody willing to help out anymore ?

john1000




msg:3779822
 10:30 am on Nov 4, 2008 (gmt 0)

anyone ?

jdMorgan




msg:3779858
 12:10 pm on Nov 4, 2008 (gmt 0)


Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{HTTP_REFERER} google\.com
RewriteCond %{REQUEST_URI} !^/forum/
RewriteRule .* http://www.example.com/forum/ [R=301,L]

If the client provides a referrer (many times, they don't) then that should work. If the client does not provide a referrer, there is no solution.

See the references cited in our forum charter for more information.

Jim

[edited by: jdMorgan at 12:10 pm (utc) on Nov. 4, 2008]

john1000




msg:3779883
 12:54 pm on Nov 4, 2008 (gmt 0)

Thanks JD , but im missing something...

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]

jdMorgan




msg:3779978
 3:37 pm on Nov 4, 2008 (gmt 0)

You asked for every request referred from google to be redirected to the forum, which is what that code does. Please be extremely careful (and specific) about which URLs should be redirected, and which should not. It is impossible to code a solution until the actual requirements have been exactly-defined.

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

john1000




msg:3780005
 4:14 pm on Nov 4, 2008 (gmt 0)

Indeed JD, thats the idea:

"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/"

as far as i can say is that it has 6 digits in its page creation.

jdMorgan




msg:3780038
 4:45 pm on Nov 4, 2008 (gmt 0)


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]

Note that this will only redirect requests to the forum subdomain which are referred from google and which include a Referer header.

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

john1000




msg:3780045
 5:03 pm on Nov 4, 2008 (gmt 0)

Thank you very much for your time Jim.
I will give this a try.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved