我有一个网站 (php),我将其上传到主机,但无法访问,显示 500 内部服务器错误消息。 我在 localhost 和其他 2 台主机上使用相同的 .htaccess 拥有相同的站点,它们运行良好。
服务器的错误信息如下:AH01276:无法提供目录/home/user/public_html/
这是我在 public_html 文件夹中的 .htaccess(正如我所说,它在其他 2 个主机上是相同的,没有问题)
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /public_html/
RewriteRule ^$ /public/index.php [QSA,L]
RewriteRule (.*) /public/$1 [QSA,L]
</IfModule>
如果我注释掉
RewriteRule (.*) /public/$1 [QSA,L]行,站点会加载到登录页面,但在我登录后,它会出现 404 错误。
站点是php,使用MVC模型,将每个请求重定向到public/index.php
有没有人知道这台主机上会出现什么问题?
我在 document_root/public/ 文件夹中还有另一个 .htaccess,它在每个主机上也是一样的:
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]
答案 0 :(得分:1)
您应该从两个 RewriteBase
文件中删除 .htaccess
指令。在您的根 .htaccess
文件中没有使用它(但设置不正确)。在 /public/.htaccess
文件中,RewriteBase
设置不正确,最终会将请求重写回根目录(这可能不是本意)。
还要确保在 DirectoryIndex
文件中正确设置了 /public/.htaccess
:
DirectoryIndex index.php