Nginx 解决方案:

在 /etc/nginx/config.d/mysit.conf文件的 loction \ {} 中添加

if (-f $request_filename/index.html){
    rewrite (.*) $1/index.html break;
}

if (-f $request_filename/index.php){
    rewrite (.*) $1/index.php;
}

if (!-f $request_filename){
    rewrite (.*) /index.php;
}

 

Apache解决方案:

etc/httpd/conf/httpd.config 文件

原因一:Apache中的rewrite模块没有开启,去除这一行前面的#号就可以了

LoadModule rewrite_module modules/mod_rewrite.so

原因二:AllowOverride Not Enabled;服务器可能没打开AllowOverride。如果httpd.config的AllowOverride设置的是None,那.htaccess将被忽略。找到以下2处位置并修改:

<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/html>
# … other directives…
AllowOverride All
</Directory>

修改完成后,要重启Apache才能生效。

service httpd restart

 

相关文章:

  • 2021-04-13
  • 2022-01-10
  • 2022-02-17
  • 2021-04-25
  • 2022-12-23
  • 2021-12-20
  • 2021-05-23
  • 2021-11-09
猜你喜欢
  • 2021-11-27
  • 2021-08-07
  • 2022-12-23
  • 2021-10-02
  • 2021-11-16
  • 2021-08-27
  • 2021-06-07
相关资源
相似解决方案