You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MacPorts AMP环境下Drupal10本地站点登录页面404问题求助

解决Drupal 10登录链接404错误的办法

1. 修正Drupal站点基础URL配置

  • 进入站点配置目录:/Users/me/Sites/mysite/web/sites/default,若未生成settings.php,先复制default.settings.php并重命名为settings.php
  • 编辑settings.php,找到$base_url项,取消注释并设置为:
    $base_url = 'http://mysite.local';
    
    该配置会让Drupal生成不含多余/web后缀的正确URL。

2. 启用Apache Rewrite模块

  • 通过MacPorts启用模块:
    sudo port load apache2
    sudo apxs -a -e -n rewrite mod_rewrite.so
    
  • 重启Apache服务:
    sudo port restart apache2
    

3. 调整虚拟主机配置细节

  • 修正DocumentRoot的路径格式,将原配置中的转义斜杠改为普通斜杠:
    DocumentRoot "/Users/me/Sites/mysite/web"
    
  • 确认<Directory>块路径与DocumentRoot完全一致,且AllowOverride All已正确设置,确保Drupal根目录的.htaccess规则能生效。

4. 检查.htaccess文件状态

  • 确认/Users/me/Sites/mysite/web目录下存在.htaccess文件(Composer安装的Drupal默认自带),若缺失,从Drupal源码包中复制对应文件到该目录
  • 设置正确的文件权限,保证Apache可读取:
    chmod 644 /Users/me/Sites/mysite/web/.htaccess
    

完成以上操作后重启Apache,再次访问站点点击登录链接,将跳转至正确的http://mysite.local/user/login路径,404问题即可解决。

内容的提问来源于stack exchange,提问作者murray

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 17:45:33