Forum Moderators: phranque

Message Too Old, No Replies

htaccess problem 301 rediect can you help

Please

         

webdev

11:29 pm on Jun 6, 2003 (gmt 0)

10+ Year Member



Hi

I have two probs

1) when I place the following code into my files this happens

File code :

redirect 301 /forums [mysite.com...]

Results in being redirected to [mysite.com...]

Notice the trailing end slash I don't want that....

2)I have a large amount of sub topics that are php generated in Google like so

[mysite.com...] id= etc....

Can I place a line in my file that will forward everything from /froums/ to [mysite.com...]

Also if I put them in individually like this

redirect 301 /forums/viewtopic?topic id= etc [mysite.com...]

the it results in being redirected to

[mysite.com...] id= etc

Any help, much appreciated

jdMorgan

11:49 pm on Jun 6, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



webdev,

For problem #1, I'd suggest switching to RedirectMatch to prevent the left-side URL suffix from being appended to the the right-side URL. Remember that Redirect [httpd.apache.org] uses prefix-matching; If the prefix pattern matches, the suffix (whatever is left over) is appended to the destination URL. Thus, this extra slash you are seeing came from the requested URL, in all liklihood, "/forums/" -- remembering that your server will append a slash to any directory when it is missing. See the Redirect documentation if this is not clear.

RedirectMatch will allow you to explicitly specify which parts of the URL you want to back-reference from the source URL for use in the destination URL.

Problem #2 isn't clear to me - can you give several examples, and perhaps describe the goal you have in mind?

mod_alias in general doesn't deal well with query strings, and you may need to use mod_rewrite to solve #2.

Jim

webdev

11:59 pm on Jun 6, 2003 (gmt 0)

10+ Year Member



Hi thanks for the post

The second issue is basically I have a large amount of forum topics indexed in google under their topic id's

So for example

[mysite.com...]

There is literally hundreds of these....

As these have all moved I'm not worried about losing them in google I just want a redirect for all of the to go to

[mysite.com...]

At the moment the root forum redirects but all of these individual files produce 404 error so I'm looking for a way to redirect everyting underneath /forums/ to be redirected to the new location [mysite.com...] otherwise I'd have to place hundreds of redirects in my htaccess file listing them all one by one...

webdev

12:02 am on Jun 7, 2003 (gmt 0)

10+ Year Member



Also can you give me an idea as to the Match syntax I should use for the first issue.

thanks

jdMorgan

1:41 am on Jun 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



webdev,

This should take care of both problems:


RedirectMatch 301 ^/forums http://www.mysite.com/portal/index.php

If your topic numbers have not changed, you might try the following - placing it BEFORE the directive above. I'm not sure it'll work, but it might. If not, you can use mod_rewrite to do the same thing - map the old URL to the new one, and preserve the topic number. With mod_rewrite, you also have the option of doing a "transparent" or server-internal redirect, which means Google will NOT know the pathname has changed, and your URLs listed in their SERPs will continue to benefit you.


RedirecMatch 302 ^/forums/topic(.*)$ http://www.mysite.com/portal/index.php?topic$1

Jim

webdev

10:12 am on Jun 7, 2003 (gmt 0)

10+ Year Member



Thanks JD the first one seems to be working a treat....

All of the topic id have changed I'm afraid to the second one won't work in this instance...

Thanks again