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

如何从URL中移除目录名?PrestaShop 1.7.8.7站点配置求助

解决PrestaShop 1.7.8.7直接通过domain.com访问的问题

1. 修正服务器文档根目录配置

核心问题是当前域名的文档根目录未指向PrestaShop的实际部署目录/public_html/home,导致访问时需要手动拼接子目录路径。根据你使用的服务器类型调整:

Apache环境

找到域名对应的虚拟主机配置文件(通常位于/etc/apache2/sites-available/目录),修改DocumentRoot及目录权限配置:

DocumentRoot /public_html/home
<Directory /public_html/home>
    AllowOverride All
    Require all granted
</Directory>

修改完成后重启Apache服务:

sudo systemctl restart apache2

Nginx环境

打开域名对应的Nginx配置文件(通常位于/etc/nginx/sites-available/目录),调整root字段指向PrestaShop部署目录:

server {
    listen 80;
    server_name domain.com www.domain.com;
    root /public_html/home;
    index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ /index.php$is_args$args;
    }

    # 保留原有PrestaShop相关的location规则
}

修改完成后重启Nginx服务:

sudo systemctl restart nginx

2. 更新PrestaShop后台URL配置

登录PrestaShop后台,按以下路径调整配置:

  • 进入首选项 > 商店参数 > 联系信息:将「商店URL」和「SSL URL」(若启用HTTPS)修改为https://domain.com
  • 进入首选项 > 商店参数 > 流量与SEO:确保「基础URL」设置为https://domain.com/

3. 调整.htaccess文件(仅Apache环境)

打开/public_html/home/.htaccess文件,找到RewriteBase行并修改:

# 原配置可能为 RewriteBase /home/
RewriteBase /

4. 清除PrestaShop缓存

进入后台高级参数 > 性能,点击「清除缓存」按钮,确保旧的URL配置缓存被清空。

完成以上步骤后,访问domain.com即可直接打开PrestaShop首页。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.08 16:10:30