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

本地WAMP环境中Craft 3 CMS站点单页面显示"Index Of /"的原因

Troubleshooting "Index Of /" on Craft 3 Resources Page (Local WAMP)

Hey there, let's tackle this frustrating issue you're having. It's odd that only your resources page is showing that directory listing, especially since it works in production and another local WAMP environment. Here are the most likely fixes to try, ordered by how common they are:

1. Fix Apache's DirectoryIndex for Your Virtual Host

Chances are, the virtual host for this Craft site isn't prioritizing index.php (Craft's entry point) over static files like index.html. That's why adding /index.html works, but the plain URL falls back to directory listing.

  • Open your WAMP's httpd-vhosts.conf file (usually in C:\wamp64\bin\apache\apacheX.X.X\conf\extra).
  • Locate the <Directory> block for your site's web root.
  • Make sure it includes index.php as the first entry in the DirectoryIndex directive:
    <Directory "C:/wamp64/www/your-craft-site/web">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require local
        DirectoryIndex index.php index.html index.htm
    </Directory>
    
  • Save the file, restart Apache from the WAMP manager, and test the resources page again.

2. Verify Craft's .htaccess and mod_rewrite

Craft relies on mod_rewrite and the root .htaccess file to route all requests through index.php. If either is misconfigured, certain pages might bypass Craft's routing.

First, enable mod_rewrite:

  • Right-click the WAMP tray icon → Apache → Apache Modules → Ensure rewrite_module is checked. Restart Apache if you had to enable it.

Then, check your web root's .htaccess:

Navigate to your Craft site's web directory and open .htaccess. Ensure it has the standard Craft rewrite rules (don't worry if some extra rules are present, but these core ones should exist):

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Send would-be 404 requests to Craft
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?p=$1 [QSA,L]
</IfModule>

If the file is missing or modified, you can restore the default Craft .htaccess content (it's the standard routing setup for Craft 3).

3. Clear Craft's Routing Cache

Sometimes local caching can cause routing inconsistencies, even if other environments work. Let's flush Craft's caches:

  • Option 1: Log into your Craft admin panel → Go to Settings → Caching → Click Clear All Caches.
  • Option 2: Open a terminal in your Craft site's root directory and run:
    ./craft clear-caches/all
    
    (If you're on Windows, use php craft clear-caches/all instead.)

4. Double-Check Virtual Host Document Root

Make sure your virtual host's DocumentRoot points directly to Craft's web folder, not the site's root directory. For example:

<VirtualHost *:80>
    ServerName yourcraftsite.local
    DocumentRoot "C:/wamp64/www/your-craft-site/web"
    # ... other configs ...
</VirtualHost>

If it's pointing to the parent folder, Apache might be trying to list the contents of a "resources" directory instead of passing the request to Craft's index.php.

5. Check Folder Permissions (Less Likely, But Worth Trying)

On Windows, WAMP sometimes has weird permission quirks even if it's local. Right-click your Craft site's web folder → Properties → Uncheck the "Read-only" box (apply to all subfolders/files) and click OK. Restart Apache afterward.


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 12:05:07