PDA

View Full Version : Misc Any apache server experts here?


penguinz
01-20-2009, 01:17 PM
I need some help with a 302 redirect in .htaccess. Anyone here good with this?

Simplex3
01-20-2009, 01:22 PM
Define "good".

EyePod
01-20-2009, 01:22 PM
I'm not, but good luck! I just came in here to see if anyone actually knew what you were talking about!

Simplex3
01-20-2009, 01:24 PM
It's just:

REDIRECT 302 /path/to/redirect URI/to/redirect/to

Simplex3
01-20-2009, 01:25 PM
Also, are you sure it's a 302 (temporary) that you want?

Simplex3
01-20-2009, 01:27 PM
IIRC you can also use "temporary" and "permanent" in place of 302 and 301, respectively.

penguinz
01-20-2009, 01:32 PM
I meant 301.

On one of the sites I own I moved the forums to a subdirectory so I need the query strings to redirect to the subforum and return the 301 for SEO.

Simplex3
01-20-2009, 01:34 PM
So if the .htaccess was in the root of the site, the redirect would be:

REDIRECT 301 /forums http://my.server.tld/newforums/

The first path is relative to the place where the .htaccess file is, the second is the full URI to the new resource.

Kerberos
01-20-2009, 01:36 PM
0100100100100000011101110110100101110011011010000010000001001001001000000110100001100001011001000010 0000011100110111010001110101011001000110100101100101011001000010000001101101011011110111001001100101 0010000001101111011011100010000001010101010011100100100101011000001000000110000101101110011001000010 0000010011000110100101101110011101010111100000100000011101110110100001100101011011100010000001001001 0010000001101000011000010110010000100000011101000110100001100101001000000110001101101000011000010110 1110011000110110010100101110

penguinz
01-20-2009, 01:37 PM
I should have given an example. There is still going to be content in the root I don't want redirected.

http://www.mysite.com/index.php?showforum=22 to http://www.mysite.com/forums/index.php?showforum=22

Dave Lane
01-20-2009, 01:43 PM
I think Simplex got for you just substitute your urls for his...

Simplex3
01-20-2009, 01:46 PM
So it's only some topics, forums, etc? Some index.php things are still here, some are now over there? For that you'll have to use mod_rewrite, something like:

RewriteCond %{QUERY_STRING} ^showforum=22$ [NC]
RewriteRule index.php http://my.server.tld/newforums/newpage? [R=301,L]

Simplex3
01-20-2009, 01:52 PM
I think Simplex got for you just substitute your urls for his...

Actually, no. The REDIRECT command is kind of like a chainsaw. Great for dismembering someone after you kill them, but not really good for torturing them for extended periods of time.

Or something like that.

penguinz
01-20-2009, 01:57 PM
Not working :(

Simplex3
01-20-2009, 01:59 PM
Not working :(

Show me what you've put in so I can check the urls. PM me if you don't want to spread it around.

Simplex3
01-20-2009, 02:14 PM
I think Simplex got for you just substitute your urls for his...

Actually, no. The REDIRECT command is kind of like a chainsaw. Great for dismembering someone after you kill them, but not really good for torturing them for extended periods of time.

Or something like that.

Saulbadguy
01-20-2009, 02:15 PM
Who uses that shit anymore? IIS7 FTW!!!!!

;)

Fritz88
01-20-2009, 02:39 PM
I worked with it for a while, not enough experience. Good luck .

Simplex3
01-20-2009, 02:46 PM
For the record, the answer was:

RewriteCond %{QUERY_STRING} !^$
RewriteRule .* http://www.mydomain.tld/forums/index.php?%{QUERY_STRING} [R=301,L]

It worked for him because only the forums had a query string.

penguinz
01-20-2009, 02:51 PM
Who uses that shit anymore? IIS7 FTW!!!!!

;)All the sites I get paid to manage are Windows. I do not have that luxury for this one.