Forum Moderators: phranque

Message Too Old, No Replies

changed directories from root to forums

         

biglamb

4:58 pm on Nov 13, 2008 (gmt 0)

10+ Year Member



I am sure this has been posted here or something close but and I have flipped through a lot of pages for three days on numerous sites before I broke down to ask and I apologize but I need help.

Apache
Vbull
vbadvanced
changed directories from root to forums

simple right?
so I thought, I am losing it...

All links sitting on google for forum posts point to eg. http://www.example.com/showthread.php?t=2220
Crrently I get a 404 error due to the fact its now here http://www.example.com/forums/showthread.php?t=2220

Now without writing redirects for each indvidual thread is there an easier way? Can there not be wildcards involved?

I have tried numerous things so many I cannot name them all so I am forced to ask, any help would be greatly appreciated

[edited by: jdMorgan at 5:17 pm (utc) on Nov. 13, 2008]
[edit reason] Use example.com only, please. See TOS. [/edit]

jdMorgan

5:20 pm on Nov 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As described, this is a simple one-additional-line-of-code problem. Please post your best-effort coding attempt as a basis for discussion.

Thanks,
Jim

biglamb

5:28 pm on Nov 13, 2008 (gmt 0)

10+ Year Member



RewriteEngine On

RewriteCond %{QUERY_STRING} ^t=#*$!X$
RewriteRule ^showthread\.php$ [domain.com...] [L,R=301]

This what I have been working with if I do each individual thread. I figured I was on the correct path here but so far nothing. I was hoping not to have to do each individual thread. I have to say my lack of planning has come to bite me on this as I figured a simple redirect to a new directory would not be a problem.

jdMorgan

5:37 pm on Nov 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you do not specify a new query string, mod_rewrite passes the existing query unchanged through the rules. Therefore, all you need is a one-line rule in www.example.com/.htaccess:

RewriteEngine on
#
RewriteRule ^showthread\.php$ http://www.example.com/forums/showthread.php [R=301,L]

If this is your first and only rule, and it doesn't work and you get a 500-Server Error, then you will likely need to add

Options +FollowSymLinks

ahead of the RewriteEngine directive. Do this only if needed, though, as some hosts have it set by default and do not allow you to set or change Options. Therefore, if it's not needed, adding it may cause an error.

Jim

biglamb

6:30 pm on Nov 13, 2008 (gmt 0)

10+ Year Member



Thanks man, I have some new insite now for mod_rewrite, ever get around Dallas way and I will buy you a drink, peace and chicken grease

jdMorgan

6:43 pm on Nov 13, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Bad luck, Bubba -- I'm just 3 beers north of you... :)

If you don't already have other rules in your .htaccess file, do take a look around here at the forum library and some of the recent threads. You should canonicalize your domain and URLs to prevent duplicate content problems at the least, and there are other useful code samples concerning site security.

Jim

biglamb

6:52 pm on Nov 13, 2008 (gmt 0)

10+ Year Member



Yes I agree, I will be using this as one of my sources. My main concern has been duplicate content, unfortunately my time has been limited. Again thanks for the help.