PDA

View Full Version : How to setup a 301 redirect correctly


tommyxv
05-05-2006, 10:52 AM
Please chime in of you can help. I changed my directory structure the other day. My forums use to be located at www.mysite.com/vbforums

I move it to www.mysite.com/forums

How and where do I setup a redirect for all the old links?

Thanks,

Boofo
05-05-2006, 10:58 AM
Make this your htaccess file in the vbforums root directory.

Options +Indexes +FollowSymlinks
RewriteEngine on
RewriteBase /
#
RewriteRule index.html www.mysite.com/forums/$1 (http://www.mysite.com/forums/$1) [R=301,L,NC]
#

tommyxv
05-06-2006, 12:36 AM
I tried it but it did not work. :(

SaN-DeeP
05-06-2006, 02:42 AM
put this code in your root .htaccess file

RewriteRule ^vbforums.* http://www.mysite.com/forums [NC,L,R]

Regards,

Boofo
05-06-2006, 03:22 AM
put this code in your root .htaccess file

RewriteRule ^vbforums.* http://www.mysite.com/forums [NC,L,R]

Regards,

Ahhh, the man who taught me about this stuff. How come the code I posted didn't work? It was what you gave me for mine and it works for me. ;)

tommyxv
05-06-2006, 12:05 PM
put this code in your root .htaccess file

RewriteRule ^vbforums.* http://www.mysite.com/forums [NC,L,R]

Regards,

Ok, it is sort of working now.

My old links look like this:
http://www.mysite.com/vbforums/showthread.php?t=19549

The redirect urls look like this and doesn't show the correct page:
http://www.mysite.com/forums/?t=19549


Here is a little twist too. My forums are setup on a sub-domain: http://forums.mysite.com which points to http://www.mysite.com/forums

It will work either way but I would like to have the redirect urls look like my current forum urls:
http://forums.mysite.com/showthread.php?t=19549

My htacces currently looks like this

Options +Indexes +FollowSymlinks
RewriteEngine on
RewriteRule ^vbforums.* http://www.mysite.com/forums [NC,L,R]

I also tried this to get the urls on the sub-domain but it still cuts off the "showthread.php" part

Options +Indexes +FollowSymlinks
RewriteEngine on
RewriteRule ^vbforums.* http://forums.mysite.com [NC,L,R]

And I did remember to replace "mysite" with my info. LOL :)

Thanks in advance Boofo & SaN-DeeP. :)

SaN-DeeP
05-08-2006, 11:17 PM
is your problem fixed ?

tommyxv
05-09-2006, 01:02 PM
is your problem fixed ?

No :(

My old links look like this:
http://www.mysite.com/vbforums/showthread.php?t=19549

The redirect urls look like this and doesn't show the correct page:
http://www.mysite.com/forums/?t=19549

treasureman
05-09-2006, 01:20 PM
Try this:

RewriteRule ^vbforums/(.*)$ forums/$1 [L,R=301]

tommyxv
05-11-2006, 04:13 AM
Yeap that did. Thanks everyone. :banana: