Change to .htaccess causes error 500

Discussion in 'Apache' started by marbuy, Jun 18, 2010.

  1. #1
    Already some time ago, I migrated my (hosted) website from a Windows to a Linux/Apache/PHP environment. The move also caused a reorganization of the structure of the website, so I created a simple .htaccess file to do some redirects:

    RedirectMatch permanent (.*)\.htm$ $1.php
    Redirect permanent /english/dir1 http://www.mysite.com
    Redirect permanent /english/dir2 http://www.mysite.com
    Redirect permanent /english/dir3 http://www.mysite.com
    ErrorDocument 404 http://www.mysite.com/404.php

    This has always worked fine. However, in the statistics, I still saw a lot of requests for the page default.php. In the previous Windows environment, default.htm was the homepage. Apparently, several sites or bookmarks still contained this reference to the old homepage, which were now being redirected to default.php. However, on the Linux system, this page does not exist since index.php is the homepage. So, I decided to add another redirect to the .htaccess file to handle this:

    RedirectMatch permanent (.*)\.htm$ $1.php
    Redirect permanent /english/dir1 http://www.mysite.com
    Redirect permanent /english/dir2 http://www.mysite.com
    Redirect permanent /english/dir3 http://www.mysite.com
    Redirect permanent default.php index.php
    ErrorDocument 404 http://www.mysite.com/404.php

    However, after upload, this results in an error 500 while accessing the site. I am not an expert in these things, but the code looks correct, so what is causing this? A better way of writing this?
     
    marbuy, Jun 18, 2010 IP
  2. bvsonline

    bvsonline Peon

    Messages:
    83
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi,

    Try this rule set.


    Redirect permanent /default.php mysite.com/index.php
     
    bvsonline, Jun 19, 2010 IP
  3. marbuy

    marbuy Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you very much! That does the trick! Apparently, my understanding of the 'correct' syntax wasn't as correct as I thought...
     
    marbuy, Jun 19, 2010 IP
  4. roopajyothi

    roopajyothi Active Member

    Messages:
    1,302
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #4
    Remove http://www in that :)
     
    roopajyothi, Jun 20, 2010 IP