homepage Welcome to WebmasterWorld Guest from 54.145.172.149
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
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

5+ Year Member



 
Msg#: 3777822 posted 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

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3777822 posted 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

5+ Year Member



 
Msg#: 3777822 posted 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

5+ Year Member



 
Msg#: 3777822 posted 1:36 am on Nov 2, 2008 (gmt 0)

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

john1000

5+ Year Member



 
Msg#: 3777822 posted 10:30 am on Nov 4, 2008 (gmt 0)

anyone ?

jdMorgan

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3777822 posted 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

5+ Year Member



 
Msg#: 3777822 posted 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

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3777822 posted 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

5+ Year Member



 
Msg#: 3777822 posted 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

WebmasterWorld Senior Member jdmorgan us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 3777822 posted 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

5+ Year Member



 
Msg#: 3777822 posted 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.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved