Click to See Complete Forum and Search --> : 301 redirect not working


Sculleybe
06-26-2009, 08:11 PM
I am pretty new to web development and just updated a site. There are 5 pages from the old site that need to be redirected to a relavant page on new site. The domain name remained the same. The site is hosted on a Linux server (Godaddy). I have created an .htaccess file and uploaded it as ASCII but it's not working. It's named .htaccess and uploaded to my root folder. The contents are below with "domain.com" being the URL (same in old and new). Is the below correct? Do I list all five items like below with a space between, etc?

RewriteEngine on
rewritecond %{http_host} ^http://www.domain.com/aboutus.html [nc]
rewriterule ^(.*)$ http://www.domain.com/about/$1 [r=301,nc]

RewriteEngine on
rewritecond %{http_host} ^http://www.domain.com/faq.html [nc]
rewriterule ^(.*)$ http://www.domain.com/about/$1 [r=301,nc]

RewriteEngine on
rewritecond %{http_host} ^http://www.domain.com/plans.html [nc]
rewriterule ^(.*)$ http://www.domain.com/architectural/$1 [r=301,nc]

RewriteEngine on
rewritecond %{http_host} ^http://www.domain.com/resources.html [nc]
rewriterule ^(.*)$ http://www.domain.com/about/$1 [r=301,nc]

RewriteEngine on
rewritecond %{http_host} ^http://www.domain.com/building.html [nc]
rewriterule ^(.*)$ http://www.domain.com/ourwork/index.html/$1 [r=301,nc]

nickpalmigiano
06-29-2009, 11:06 AM
I'm fairly new to using htaccess as well, however I'm pretty certain that you only need to have your RewriteEngine On listed once before all subsequent redirects.

also, are you getting a 500 Server error or just nothing happening?

Sculleybe
06-29-2009, 11:27 AM
Thanks for helping, Nick. Here's the code I came up with after getting some help but still not working. I'm getting a 404 error.

RewriteEngine on
RewriteRule ^/?(aboutus|faq|resources)\.html$ about/$1.html [R=301,L]
RewriteRule ^/?plans\.html$ architectural/plans.html [R=301,L]
RewriteRule ^/?building\.html$ ourwork/index.html/plans.html [R=301,L]

nickpalmigiano
06-29-2009, 01:46 PM
Well, the 404 is a page not found error. Did you make sure that the pages you are pointing the redirects to exist?

Also, since they're 301 is the url changing in the url box in your browser to reflect the redirect?

Sculleybe
06-29-2009, 03:36 PM
Hey Nick,

Thanks again for your help. I found someone to help me and got it working. This is what worked:

redirect 301 /aboutus.html http://www.example.com/about/index.html
redirect 301 /faq.html http://www.example.com/about/index.html
redirect 301 /plans.html http://www.example.com/architectural/index.html
redirect 301 /resources.html http://www.example.com/about/index.html
redirect 301 /building.html http://www.example.com/ourwork/index.html
redirect 301 /testimonials.html http://www.example.com/testimonials/index.html