dcsimg
www.webdeveloper.com
Results 1 to 5 of 5

Thread: 301 redirect not working

Hybrid View

  1. #1
    Join Date
    Jun 2009
    Posts
    17

    301 redirect not working

    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]

  2. #2
    Join Date
    Jun 2009
    Posts
    5
    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?

  3. #3
    Join Date
    Jun 2009
    Posts
    17
    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]

  4. #4
    Join Date
    Jun 2009
    Posts
    5
    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?

  5. #5
    Join Date
    Jun 2009
    Posts
    17

    301 Redirect multiple files

    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles