Forum Moderators: phranque

Message Too Old, No Replies

301 htaccess Help Needed

301 Redirect Help Please

         

webdev

9:20 am on Sep 29, 2003 (gmt 0)

10+ Year Member



Hi all

I currently have

www.mysite.com/forums/showthread.php?&threadid=259

and I need this to got to

www.mynewsite.com/showthread.php?&threadid=259

Can someone please let me know the syntax for this...also which directory should the htaccess file be uploaded into the root or the /forums/ directory..

Thanks

Alternative Future

9:43 am on Sep 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi webdev,

This .htaccess might do what you are after and belongs in the root of your site.

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST}!^www\.mynewsite\.com
RewriteRule ^(.*)$ [mynewsite.com...] [R=permanent,L]

Let's know the outcome as I am still learning from some of the eXpert teachers on here :)

HTH,

-gs

webdev

10:09 am on Sep 29, 2003 (gmt 0)

10+ Year Member



Hi

Before I try this can I just say that I only want redirects from the www.mysite/forums/ directory to be redirected.

the rest of my site should not change.

Basically I have moved my forums to a new domain and I want to redirect all www.mysite.com/forums/ to the new site nothing underneath

So

www.mysite.com should stay on www.mysite.com

and

www.mysite.com/forums/ should go to www.mynewsite.com/

Alternative Future

10:17 am on Sep 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ah ok,

Then the .htaccess would be placed in your forums directory only (old site that is).

The one I suggested should still work from there.

-gs

webdev

10:26 am on Sep 29, 2003 (gmt 0)

10+ Year Member



Hi

This is the response I get from the above code...

Hello 195.92.109.226(195.92.109.226)

A 500 error occurred when I tried to retrieve [mysite.com...] for you. This means Internal Server Error.

I tried to access the following URL

[mysite.com...]

Any ideas...

Thankyou

Alternative Future

10:37 am on Sep 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi,

Can you look at the server log, specifically the error_log file. And give more on the error?

-gs

Alternative Future

10:43 am on Sep 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here is something else that might be of use:


Common Problems with 500 Server Error

Many times people report a "500 Server Error" when creating/modifying their .htaccess or .htgroup files. Nine out of ten times this is caused by one of two things. 1) The file was transferred to the server using FTP in Binary mode rather than ASCII. 2) There is no "new-line" or "carriage return" on the last line of the file. This too can be caused by transferring the file in Binary mode. Please re-transfer the file using FTP ensuring that you are transferring it in ASCII mode.

-gs

webdev

10:52 am on Sep 29, 2003 (gmt 0)

10+ Year Member



I'd love to but I can't seem to get to it......shared hosting etc.....

How a bout a Redirect Match type of htaccess file would this work...

Alternative Future

10:55 am on Sep 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could try looking over this post [webmasterworld.com]
[OR]
This one [httpd.apache.org]

This might be a silly question but you do have full access to the mod_rewrite on your shared server yeah?

-gs

webdev

11:00 am on Sep 29, 2003 (gmt 0)

10+ Year Member



Yep I believe so

My current .htaccess that I have set up works like this:

Redirect 301 /forums/ [mynewsite.com...]

This works a charm but doesn't append the individual pages for me.

Alternative Future

11:11 am on Sep 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can you post that .htaccess for me to have a look @?

-gs

webdev

11:12 am on Sep 29, 2003 (gmt 0)

10+ Year Member



I have thats it currently above...

In the root of my domain...

Alternative Future

11:22 am on Sep 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ah ok then in that case am unsure of where the problem lies with the new one!

There should be somemore eXperienced mod_rewrite guyz coming on soon that might be able to answer your initial query.

Sorry I couldn't help :(

-gs

webdev

11:33 am on Sep 29, 2003 (gmt 0)

10+ Year Member



No probs thanks for all your help so far much appreciated :)

closed

8:43 pm on Sep 29, 2003 (gmt 0)

10+ Year Member



Put this in your .htaccess and upload it to your forums directory:

RewriteEngine on
RewriteRule ^(.*)$ http://www.mynewsite.com/$1 [R=301,L]

I removed the Options +FollowSymlinks because you probably don't need it. Of course, if you get an error, then try putting it in.

bpresent

11:49 pm on Sep 29, 2003 (gmt 0)



I'm still new to this stuff myself so take that as a warning but....

Assuming that you have only got one site (the old one) pointed to this home directory (and perhaps depending on other things) I reckon this should work (in the root directory):

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^forums\/(.*)$ http://www.mynewsite.com/$1 [R=301,L]

Failing that, wait for jdmorgan to post... :)

Also, be warned: if you have the type of host that does not display .htaccess files in windows clients such as WSFTP it is possible that you have accidentally loaded an .htaccess into a sub-directory. This can wreak havoc (and 500s)! Loading an empty .htaccess is not a good option - you'll have to get in with native ftp and delete the dud files.

[edit - just realised on posting the above is identical to 'closed's' post - the only difference being the relative directory - you get the gist anyway - depends on if you want one .htacess for the site or one for each major directory]

webdev

10:45 am on Sep 30, 2003 (gmt 0)

10+ Year Member



Thanks very much for this works like a charm.