.htaccess nightmare

Discussion in 'Apache' started by DigiNewb, May 28, 2011.

  1. #1
    I've been trying for hours to get my .htaccess file to work to no avail. I'm kind of a newb so I'm probably doing something wrong.. I was hoping someone could take a look at my .htaccess file and tell me what I'm not doing correctly.

    Here's my situation: I've had a wordpress website for a long time and have lots of pages on it. Recently I started a forum and copied all of the content from my old website over to the new one. I want to permanently redirect most (but not all) of the pages from my old website to pages on my new website using a 301 redirect in the .htaccess file, but it's turned out to be a nightmare. The results are horribly inconsistent with some pages working, some pages coming up with a "The webpage cannot be found" error, some pages redirecting to the new domain but extra slashes added in the url, and some where all of the slashes are right but the word "test" is appended to the end of the url about twenty times. It's nuts! Try the last one, for example.

    My .htaccess file, located at roboticsguy.com:
    Redirect 301 /links /resources
    Redirect 301 /projects/build-a-cheap-diy-cnc-machine http://www.robotenthusiasts.com/forum/viewtopic.php?f=18&t=29
    Redirect 301 /arnold-schwarzenegger-is-back-in-the-governator-2 http://www.robotenthusiasts.com/forum/viewtopic.php?f=15&t=53
    Redirect 301 /balancing-robot-attempt-2 http://www.robotenthusiasts.com/forum/viewtopic.php?f=23&t=40
    Redirect 301 /tutorials/pic-microcontrollers/hd44780-lcd http://www.robotenthusiasts.com/tutorials/?p=10
    Redirect 301 /mplab-x-ide-first-look http://www.robotenthusiasts.com/forum/viewtopic.php?f=9&t=52
    Redirect 301 /cheap-linear-rails-idea-for-cnc-machines http://www.robotenthusiasts.com/forum/viewtopic.php?f=19&t=49
    Redirect 301 /tutorials/pic-microcontrollers/configuring-the-pic18f4550-10-bit-adc-module http://www.robotenthusiasts.com/tutorials/?p=14
    Redirect 301 /projects/electronics/pic18f4550-usb-board http://www.robotenthusiasts.com/forum/viewtopic.php?f=35&t=58
    Redirect 301 /tutorials/pic-microcontrollers/pic18f4550-timer0 http://www.robotenthusiasts.com/tutorials/?p=13
    Redirect 301 /tutorials/pic-microcontrollers/pic18f4550-configuration http://www.robotenthusiasts.com/tutorials/?p=12
    Redirect 301 /tutorials/printed-circuit-boards/making-pcbs-the-toner-transfer-method http://www.robotenthusiasts.com/tutorials/?p=46
    Redirect 301 /starting-out-with-smds http://www.robotenthusiasts.com/tutorials/?p=56
    Redirect 301 /tutorials http://www.robotenthusiasts.com/tutorials/
    Redirect 301 /projects/software/cnc-controller http://www.robotenthusiasts.com/forum/viewtopic.php?f=27&t=25
    Redirect 301 /projects/electronics/l297-l298-stepper-motor-controller http://www.robotenthusiasts.com/forum/viewtopic.php?f=35&t=35
    Redirect 301 /projects/electronics/dspic30f4011-prototyping-board http://www.robotenthusiasts.com/forum/viewtopic.php?f=35&t=33
    Redirect 301 /tutorials/pic-microcontrollers/dspic30f-digital-input-output http://www.robotenthusiasts.com/tutorials/?p=30
    Redirect 301 /tutorials/pic-microcontrollers/getting-started-with-pic-microcontrollers http://www.robotenthusiasts.com/tutorials/?p=45
    Redirect 301 /tutorials/vex/using-mplab-with-vex http://www.robotenthusiasts.com/tutorials/?p=32
    Redirect 301 /projects/robots/dspic-square-bot http://www.robotenthusiasts.com/forum/viewtopic.php?f=23&t=31
    Redirect 301 /projects/robots/balancing-vex-robot http://www.robotenthusiasts.com/forum/viewtopic.php?f=23&t=32
    Redirect 301 /projects/software/dspic-serial-communicator http://www.robotenthusiasts.com/forum/viewtopic.php?f=27&t=24
    Redirect 301 /tutorials/pic-microcontrollers/dspic30f-motor-control-pwm-module http://www.robotenthusiasts.com/tutorials/?p=31
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    Code (markup):
    I would greatly appreciate help! :)
     
    DigiNewb, May 28, 2011 IP
  2. DigiNewb

    DigiNewb Member

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #2
    After many hours of fruitless Googling, I finally just tried removing lines in the .htaccess file until I determined that it was a single line that was causing the problems:

    Redirect 301 /tutorials http://www.robotenthusiasts.com/tutorials/
    Code (markup):
    I don't know why that caused problems, but it sure did. I think all of the redirects are working now..
     
    DigiNewb, May 29, 2011 IP