Web Hosting Talk







View Full Version : 301 redirect in htaccess question


netcheap.com
07-01-2005, 06:37 PM
htaccess

I have a bunch of listings in google for a domain I bought.
Like domain.com/forumdisplay.php?f=3434 blah blah

How can I get these old extensions to redirect to a certain domain name. I want all of the ones in google, instead of being 404, to forward to a domain name I have. And I want to use 301 redirect, not 404 redirects. I also nee www, and non www to redirect to the www of this other domain.

Thanks

netcheap.com
07-02-2005, 02:38 AM
I can use the general cpanel redirect for the main domain, and for the file urls that would be 404, i can use the ErrorDocument 404 command in htaccess to forward to the other domain, but when checking server headers, they are 302 redirects. Any way to make them 301?

recipher
07-02-2005, 03:15 AM
Netcheap, try this, it should work.

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^oldexample.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

netcheap.com
07-06-2005, 03:58 PM
Thanks but that doesn't work.
It forwards from oldexample.com, but not www.oldexample.com or any file names to the new domain.
www.oldexample.com, www.oldexample.com/filehere.php, sub.oldexample.com do not forward.
Only the non www main domain forwards to the new domain.

I am looking to forward everything. Currently I'm using anErrorDocument 404 command line with the url after it and it works, but it's a 302 redirect in the server headers, and I need 301.

Thanks

VolkNet
07-06-2005, 04:41 PM
you can use a simple 301 redirect.

It's pretty easy just go like

redirect 301 /forumdisplay.php http://newsite.com/

put that in a .htaccess file :)

VolkNet
07-06-2005, 04:43 PM
Opps forgot to post.
Also put this in your .htaccess file.

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^yoursite\.com
RewriteRule (.*) http://www.yoursite.com/$1 [R=permanent,L]

Hope that helps! :)