apache .HTACCESS 文件导致内部服务器错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/545442/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 17:15:34  来源:igfitidea点击:

.HTACCESS File causing Internal Server Error

apache.htaccessmod-rewriteapache2

提问by Nick Woodhams

I have copied the files and database from BradPPresents.comto BradP.com.

我已将文件和数据库从BradPPresents.com复制到BradP.com

The .htaccess file is required to get pages to display properly since "Pretty URLs" are enabled by joomla!.

需要 .htaccess 文件才能使页面正确显示,因为 joomla! 启用了“漂亮的 URL”。

You can see that the database and all connections are working at http://bradp.com/index.php, however http://bradp.com/home.htmldoes not work as it relies on the .htaccess file to parse the URL.

您可以看到数据库和所有连接都在http://bradp.com/index.php工作,但是http://bradp.com/home.html不起作用,因为它依赖于 .htaccess 文件来解析网址。

I copied the identical htaccess file from bradppresents.com (currently working fine) to bradp.com and I get "Internal server error" when the file is present. As soon as it is deleted the error goes away, but of course the site does not work as needed.

我将相同的 htaccess 文件从 bradppresents.com(目前工作正常)复制到 bradp.com,当文件存在时我收到“内部服务器错误”。一旦删除,错误就会消失,但当然该站点无法按需要运行。

I'm hoping someone can shine a little light on this for me.

我希望有人能为我照亮一点。

Here's the .htaccess file

这是 .htaccess 文件

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|\.aspx|\.asp|/[^.]*)$  [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php

## This attempts to block the most common type of exploit `attempts` to Joomla!
#
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]

#max files size restrictions
php_value upload_max_filesize 20M
php_value post_max_size 20M

Here's the site configuration file from Apache.

这是来自 Apache 的站点配置文件。

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /home/nick/public_html/bradp.com/html/
        <Directory />
                Options FollowSymLinks
                AllowOverride All
        </Directory>
        <Directory /home/nick/public_html/bradp.com/html/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog /var/log/apache2/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined
        ServerSignature On

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

It's essentially the default file with a few changes.

它本质上是带有一些更改的默认文件。

I really appreciate any help I can get; Thanks a million, Nick

我真的很感激我能得到的任何帮助;感谢一百万,尼克

回答by David Schmitt

Look into your error log to see the exact error message.

查看您的错误日志以查看确切的错误消息。

But since you say "copied" in the first sentence, I assume you are moving from one host to another. The most likely cause then is that the rewritemodule is not loaded on the new server.

但是由于您在第一句话中说的是“已复制”,我假设您正在从一个主机移动到另一个主机。最可能的原因是该rewrite模块未加载到新服务器上。