由.htaccess文件导致的内部服务器错误[关闭]

I used the .htaccess codes below to redirect all request to the index files.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L,QSA]

It worked well on some remote servers, but after moving one of the sites that use it to a new server, I get the internal server error:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

What could be the cause of this error, and how can I fix it.

My guesses are that the mod_rewrite module in apache is not loaded. Check your apache configuration!

To see if that's the case, and to avoid future errors, i always place this kind of code into a check like bellow. You can try it also, see if this works and if it doesn't give you an error anymore that means that mod_rewrite is off.

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    # Checks to see if the user is attempting to access a valid file,
    # such as an image or css document, if this isn't true it sends the
    # request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php [L,QSA]
</IfModule>

You can also check by using:

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, send 404's
    # to a special page, so you can recognize the issue.

    ErrorDocument 404 /special_404_page.php
</IfModule>

Also you might wanna check the apache logs and see the error that it gives!