Forum Moderators: phranque

Message Too Old, No Replies

Need a rewrite direction

rewriting to a subfolder

         

mikesz

12:21 pm on May 6, 2009 (gmt 0)

10+ Year Member



Hello and greetings.

Thanks in advance for any help with this. I think its a simple thing to fix but for some reason I am not getting it?

I have two forum site that needed to redirect a huge number of 404 in the Google Index for my site. The first one is fixed very nicely. Thanks to all who help me with that one. The second site is different in that the forum does not run in the route so the google 404 URLs are like this one:

http://www.example.com/forums/backups-backups-backups/

When I fixed the first site, the RewriteRule was

RewriteRule ^backups-backups-backups/$ http://www.example.com/showthread.php?t=47 [L,R=301]
RewriteRule ^[^/]+/[^/]+-([0-9]+)/ http://www.example.com/showthread.php?t=$1 [L,R=301]

But this second site has a /forums subfolder that I need to deal with and for some reason nothing that I have tried has worked (I am pretty sure I have tried every combination of how /forums can be added to the rule.) I even tried to add the above in a .htaccess file that I placed in the /forums folder to no avail.

Logically (to me) seems like this ought to work but it doesn't?

RewriteRule ^forums/backups-backups-backups/$ http://www.example.com/showthread.php?t=47 [L,R=301]

I have several URL like this one that I need to take care of but I just need to get past the first one to fix them. Any ideas what I am doing wrong (besides breathing... lol).

TIA

[edited by: jdMorgan at 3:02 pm (utc) on May 7, 2009]
[edit reason] example.com [/edit]

g1smd

12:59 pm on May 6, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If the rule is going in a .htaccess file in the /forums/ folder, then use the exact same rule as before (zero changes to the pattern), because URL paths as seen by "RewriteRule" are localised to the folder where the .htaccess file is located.

[edited by: g1smd at 1:03 pm (utc) on May 6, 2009]

jdMorgan

1:01 pm on May 6, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just a guess:

In example.com/.htaccess:


RewriteRule ^forums/backups-backups-backups/$ http://www.example.com[b]/forums[/b]/showthread.php?t=47 [L,R=301]

Jim

mikesz

12:52 am on May 7, 2009 (gmt 0)

10+ Year Member



Thanks for the replies. The /forums/.htaccess worked same at the first fix. The problem was that my .htaccess didn't have the RewriteEngine On directive. I was thinking "inheritance" but apparently that logic isn't useful with using .htaccess on my server.

Once again, I thank you very much for the direction. It put me on the right track to find the problem.

Kindest regards, mikesz

g1smd

11:12 am on May 7, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Unfortunately, it is often something simple like forgetting to escape something, the rule order, omitting an option.

I used to make those errors all the time; but less often over time. I still do something silly several times per week.