我从https://github.com/crjoseabraham/php-mvc开始就遵循了基础项目 struct 在此基础上,我创建了一个php MVC项目,该项目在开发服务器AWS EC2上运行良好.我面临着绑定域名后的重定向问题.
我在Apache2.conf中为绑定域应用了以下更改.
<VirtualHost *:80>
ServerName subdomain.mydomain.com
ServerAlias www.subdomain.mydomain.com
DocumentRoot /var/www/html/project-1/public
<Directory /var/www/html/project-1/public>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/subdomain.mydomain.com_error.log
CustomLog ${APACHE_LOG_DIR}/subdomain.mydomain.com_access.log combined
</VirtualHost>
我的项目 struct :
根目录.htaccess文件的代码如下:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
公共目录.htaccess代码为:
<IfModule mod_rewrite.c>
Options -Multiviews
RewriteEngine On
RewriteBase /project-1/public
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
</IfModule>
所以,在应用上述更改后,我可以使用域名访问我的项目,它会成功打开登录页面.但当我点击菜单时,我得到的是错误信息:
内部服务器错误
服务器遇到内部错误或配置错误,并且 无法完成您的请求.
请通过[未提供地址]联系服务器管理员 告知他们此错误发生的时间,以及您采取的操作 恰好在此错误之前执行.
有关此错误的详细信息,请参阅服务器错误 原木.
为了解决这个问题,我在一个公共的.htaccess文件中应用了许多更改,但无法解决它.那么,你能帮我解决这个问题吗?
以下是我try 过的一些改变:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ public/index.php?url=$1 [QSA,L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase //
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
apache 错误日志(log):
AH00124:由于可能的配置错误,请求超过了10个内部重定向的限制.如有必要,使用‘LimitInternalRecursion’增加限制.使用‘LogLevel DEBUG’获取回溯.,Referer:http://subdomain.mydomain.com/