Apache htaccess生成一个500内部服务器错误

Apache htaccess生成一个500内部服务器错误,apache,.htaccess,Apache,.htaccess,我有一个网站(php),我上传到一个主机,它是无法访问的,给出了500内部服务器错误消息。 我在localhost上有相同的站点和相同的.htaccess,在另外两台主机上也有相同的站点,它们工作得非常好 服务器的错误消息如下:AH01276:无法服务目录/home/user/public\u html/ 这是public_html文件夹中的my.htaccess(正如我所说,在其他两台主机上也是一样的,没有问题) 您应该从两个.htaccess文件中删除RewriteBase指令。在root.

我有一个网站(php),我上传到一个主机,它是无法访问的,给出了500内部服务器错误消息。 我在localhost上有相同的站点和相同的.htaccess,在另外两台主机上也有相同的站点,它们工作得非常好


服务器的错误消息如下:AH01276:无法服务目录/home/user/public\u html/

这是public_html文件夹中的my.htaccess(正如我所说,在其他两台主机上也是一样的,没有问题)


您应该从两个
.htaccess
文件中删除
RewriteBase
指令。在root
.htaccess
文件中,未使用该文件(但设置不正确)。在
/public/.htaccess
文件中,
RewriteBase
设置不正确,最终会将请求重写回根目录(这可能不是本意)

还要确保在
/public/.htaccess
文件中正确设置了
目录索引

DirectoryIndex index.php

你试图解决什么问题?如果Apache已经抛出了一个错误,那么这与PHP有什么关系呢?我问了主机提供商,他建议注释掉我提到的那一行,就是这样。它只与php相关,因为我试图创建的站点是php。这是完整的错误消息吗?还是像研究错误代码所表明的那样,“找不到匹配的DirectoryIndex(index.php,index.html),并且Options指令禁止服务器生成的目录索引”,情况通常会这样?AH01276:无法服务目录/home/user/public_html/:没有匹配的DirectoryIndex已找到(index.php、index.php5、index.php4、index.php3、index.perl、index.pl、index.plx、index.ppl、index.cgi、index.jsp、index.jp、index.phtml、index.shtml、index.xhtml、index.html、index.htm、index.wml、Default.h、tml、Default.htm、Default.html、Default.htm、home.html、home.htm、home.htm、home.htm、index.js)以及Options指令禁止的服务器生成目录索引 RewriteRule (.*) /public/$1 [QSA,L]
Options -MultiViews
RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
 
#RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
DirectoryIndex index.php