How to Make a Discuz Forum Open at the Root URL Instead of /forum.php

Changing a Discuz home page from /forum.php to the site root is not mainly a “pseudo-static URL” problem. It is a front-page entry and canonical URL problem. In Discuz X, forum.php is the forum application entry, while index.php at the web root decides which application should answer the root request. The official Discuz X index.php source shows this dispatch logic, and the Discuz X forum.php source shows that forum.php loads the forum app and defaults an empty module to the forum index.

The safe goal is therefore: make https://example.com/ open the Discuz forum, update site navigation to the root URL, and only then add a narrow 301 from the bare /forum.php homepage to /. Do not delete forum.php, and do not redirect every forum.php?mod=... URL, because many Discuz forum list, thread, group, RSS, and redirect URLs can still depend on that entry file.

Step 1: confirm what your Discuz version is serving

Before editing rules, check the actual version and front-page settings in your Discuz admin area or source tree. If the installation has a portal enabled, a mobile domain, app domain settings, or custom default index settings, root requests may not behave like a plain forum-only installation. Test these URLs separately:

  • https://example.com/ — should load a valid page, preferably the forum index if that is the desired homepage.
  • https://example.com/index.php — should dispatch through Discuz rather than download or show source code.
  • https://example.com/forum.php — currently the duplicate homepage you want to canonicalize.
  • https://example.com/forum.php?mod=forumdisplay&fid=1 or another real forum URL — must keep working after any redirect.

Step 2: make the web server load index.php for the root

On NGINX, the NGINX index directive controls which files are checked for a slash-ending request. A typical Discuz PHP site needs index.php before static fallbacks in the relevant server or location context:

index index.php index.html;

Keep the PHP-FPM handler that is already tested on your server. Do not copy a generic front-controller rule such as “send every missing URL to /index.php” unless your Discuz installation and server design require it; a broad front-controller rule can hide real 404s or change how existing Discuz routes are handled.

On Apache, the comparable setting is the Apache DirectoryIndex directive:

DirectoryIndex index.php index.html

If you are on shared hosting and cannot edit virtual-host files, ask the host to make index.php the first index file for the Discuz document root. This is safer than trying to hide forum.php with a broad rewrite rule.

Step 3: fix application default-index loops before redirects

If requesting / already sends the browser to /forum.php, fix the Discuz application/default-index or template navigation setting first. Adding the reverse redirect from /forum.php back to / before that is fixed can create a loop: root redirects to forum.php, and forum.php redirects back to root.

After the root page works, update the visible site logo, navigation item, and any custom template link that still points to /forum.php. If Discuz has a default-index or domain-app setting in your version, use the built-in setting rather than editing core files. Core file edits tend to be overwritten by upgrades and can break mobile or domain routing.

Step 4: add only a narrow canonical redirect

Only redirect the bare homepage duplicate. The redirect must not catch forum.php?mod=... URLs, and it should not touch POST requests. A safe NGINX pattern is to classify only GET/HEAD requests for the exact /forum.php request URI, then return 301 from inside the existing virtual host. Do not create a new location = /forum.php block that competes with your current PHP handler.

Place the map in the NGINX http context:

map "$request_method:$request_uri" $discuz_home_redirect {
    default 0;
    ~^(GET|HEAD):/forum\.php$ 1;
}

Then add only this check inside the existing Discuz server block that already handles PHP correctly:

if ($discuz_home_redirect) {
    return 301 /;
}

This matches GET /forum.php and HEAD /forum.php only. It does not match /forum.php?mod=..., and it does not claim that POST requests are safe to redirect.

For Apache .htaccess, restrict the redirect to the original client request, an empty query string, and GET/HEAD methods:

DirectoryIndex index.php index.html

RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^(GET|HEAD)$
RewriteCond %{THE_REQUEST} \s/+forum\.php\s [NC]
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^forum\.php$ / [R=301,L]

Verification checklist

  • / returns 200 and shows the intended Discuz forum homepage.
  • /forum.php returns 301 to / only after the root no longer redirects back to /forum.php.
  • /forum.php?mod=forumdisplay&fid=... does not get redirected to the homepage by accident.
  • Canonical tags, sitemap URLs, logo links, and navigation links prefer https://example.com/.
  • After testing, clear Discuz cache and any CDN cache so search engines and users see the same canonical URL.