Skip to content

Support web servers without PATH_INFO and subfolders - #29

Merged
codeling merged 7 commits into
mainfrom
claude/fix-view-page-urls
Oct 3, 2026
Merged

codeling merged 7 commits into
mainfrom
claude/fix-view-page-urls

Conversation

@codeling

@codeling codeling commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

This PR adds comprehensive support for web servers that don't support PATH_INFO (like nginx without proper configuration) and for W2 installations in subfolders of the web root.

Summary

W2 previously assumed PATH_INFO support for clean URLs like /index.php/Page. This change adds a VIEW configuration option to use query strings instead (?action=view&page=Page), and ensures all URLs (static assets, images, page links) correctly handle subfolder installations.

Key Changes

  • VIEW configuration option: Added VIEW setting in config.php to support web servers without PATH_INFO. When set (e.g., ?action=view&page=), page names are appended as query values instead of PATH_INFO.

  • URL generation fixes:

    • Updated pageURL() function to handle both PATH_INFO and query string modes
    • Fixed pageLink() to properly HTML-escape URLs
    • Updated upload link generation to respect VIEW setting
  • BASE_URI calculation: Changed from str_replace('/index.php', '', $_SERVER['SCRIPT_NAME']) to rtrim(dirname($_SERVER['SCRIPT_NAME']), '/\\') for more reliable subfolder detection.

  • Documentation: Expanded INSTALL.md with detailed "Web server setup" section covering:

    • PATH_INFO configuration for nginx
    • VIEW setting for servers without PATH_INFO
    • Image upload folder setup
    • Subfolder and base URL configuration
    • Static file caching headers
  • Test infrastructure:

    • Added ViewUrlTest integration test suite for query string URL mode
    • Enhanced ServerConfigTest with subfolder and VIEW setting tests
    • Updated run.sh to support W2_SUBFOLDER environment variable for testing subfolder installations
    • Added php-test.ini to disable opcache during server tests (allows config.php changes)
  • nginx configuration: Updated template to support subfolder prefixes in location rules.

Implementation Details

The pageURL() function now conditionally uses either PATH_INFO (/Page) or query string (?action=view&page=Page) format based on the VIEW setting. All page links and redirects (e.g., after saving) use this function, ensuring consistent behavior across the application.

The test infrastructure can now validate both URL modes and subfolder installations by setting environment variables, ensuring the wiki works correctly in various deployment scenarios.

Fixes #8

https://claude.ai/code/session_01Fra4GeCzm59fuM8yg5QR5a

claude added 7 commits October 3, 2026 20:35
pageURL() always inserted a '/' after VIEW, giving ?action=view&page=/Test
(leading slash in the editor title, wrong redirect after saving). Also
HTML-escape page link hrefs and drop VIEW from the upload link, which
produced a broken URL. Adds ViewUrlTest.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fra4GeCzm59fuM8yg5QR5a
Adds a 'Web server setup' section to INSTALL.md (PATH_INFO, VIEW, the images
link, subfolder installs, static files) and uses dirname(SCRIPT_NAME) for
BASE_URI instead of str_replace('/index.php', ...), which broke for other
script names and paths containing '/index.php'. Refs #8

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fra4GeCzm59fuM8yg5QR5a
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fra4GeCzm59fuM8yg5QR5a
…wiki in a subfolder

W2_SUBFOLDER=/w2 tests/Server/run.sh apache|nginx installs the wiki below /w2.
testUrlsInASubfolder checks that style sheet, icons, scripts and image URLs
carry the prefix and are served (BASE_URI derived from the script folder).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fra4GeCzm59fuM8yg5QR5a
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fra4GeCzm59fuM8yg5QR5a
@codeling
codeling merged commit 4f9a7d2 into main Oct 3, 2026
15 checks passed
@codeling codeling mentioned this pull request Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect Page URLs

2 participants