我刚将项目移至EC2,我无法使我的.htaccess正常工作以删除index.php。尝试访问我的网站时,收到以下错误消息 - "在此服务器上找不到请求的URL /营养/身份验证/登录"。我尝试了很多.htaccess文件,并在“REQUEST_URI”之间来回切换我的uri_protocol。和'自动'。
我的项目所在的文件夹结构是/ var / www / html / nutrition /
我已验证mod_rewrite已启用。当我查看phpinfo时,它显示为一个加载的模块。
我在httpd.conf中设置了AllowOverride All:
#
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride All
Require all denied
</Directory>
#
# Relax access to content within /var/www.
#
<Directory "/var/www">
AllowOverride All
# Allow open access:
Require all granted
</Directory>
config.php中的 base_url设置为:$config['base_url'] = 'http://<ip_address>/nutrition/';
config.php中的index_page设置为:$config['index_page'] = '';
uri_protocol设置为:$config['uri_protocol'] = 'REQUEST_URI';
.htaccess文件(位于Nutrition文件夹中)是:
RewriteEngine On
RewriteBase /nutrition/
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond $1 !^(index\.php|images|js|uploads|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
我知道这是一个常见的问题,我确定你已经厌倦了回答,但我尝试了许多提供的解决方案无济于事。感谢您提供的任何帮助。
我已经解决了这个问题。在httpd.conf中设置AllowOverride All的第三个选项。更新后,.htaccess开始工作。