www.webdeveloper.com
Results 1 to 4 of 4

Thread: 301 Redirect

  1. #1
    Join Date
    Feb 2007
    Posts
    43

    301 Redirect

    I'm trying to set up a .htaccess redirect for a site I've inherited. It used to use php and strings - now it is straight xhtml.

    The previous web address would be:
    www.somesite.com/home_state.php?page=careers

    The new address is:
    www.somesite.com/careers.html

    Everything I try for the 301 redirect goes to a 404 error.

    For example:
    Redirect 301 /home_state.php?page=careers http://somesite.com/careers.html

    What else might I need in the .htaccess to make this work?

  2. #2
    Join Date
    Jun 2009
    Posts
    127
    If you are getting the 404 error message you will have to check the apache server logs for the exact error message.

  3. #3
    Join Date
    Mar 2010
    Posts
    8
    this is not sufficient code for htaccess file you have to write proper code and you can find very easily on the web. Just try once.

  4. #4
    Join Date
    Feb 2007
    Posts
    43

    Solution

    Thank you "thewebhostingdi" - the first error was that Shell was not enabled. I did that with the hosting company.

    The next step was creating the right code. What I was looking for was not easily explained on any website that I could find. I had a dozen bookmarked links, none of which clearly explained what I needed. However, here is the solution - just in case others would use this post to learn:

    First, make sure that this is included:
    Code:
    RewriteEngine On
    RewriteBase /
    Next, this piece of code will redirect all exact site name changes such as
    www.somesite.com/home_state.php?page=careers
    to www.somesite.com/careers.html

    Code:
    RewriteCond %{QUERY_STRING} page=(.+)
    RewriteRule ^home_state\.php http://somesite.com/%1.html? [R=permanent,L]
    For renamed redirects, use individual code like this:
    Code:
    RewriteCond %{QUERY_STRING} page=products1
    RewriteRule ^home_state\.php http://somesite.com/products.html? [R=permanent,L]
    The above code would redirect www.somesite.com/home_state.php?page=products1 to www.somesite.com/products.html
    Last edited by visualizer03; 03-15-2010 at 05:56 PM. Reason: additional content

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