Skip to content

Commit 47b7636

Browse files
committed
fix: corrected environment configurator (#3834)
1 parent 46e7f90 commit 47b7636

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

phpmyfaq/src/phpMyFAQ/Setup/EnvironmentConfigurator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public function getRewriteBase(): string
7373
* This method ensures that URL routing works correctly and 404 errors are properly handled.
7474
*
7575
* - RewriteBase is set to the application's installation path (e.g., /faq/)
76-
* - ErrorDocument 404 is configured to route errors to the application's error handler (e.g., /faq/index.php?action=404)
76+
* - ErrorDocument 404 is configured to route errors to the application's error handler (e.g., /404.html)
7777
*
7878
* @return bool Returns true if the .htaccess file was successfully modified, false otherwise.
7979
* @throws Exception If the .htaccess file does not exist or contains syntax errors during parsing.
@@ -110,7 +110,7 @@ public function adjustRewriteBaseHtaccess(): bool
110110
$errorDocument404->removeArgument($arg);
111111
}
112112
// Set new arguments: error code and path
113-
$new404Path = rtrim($this->getServerPath(), '/') . '/index.php?action=404';
113+
$new404Path = rtrim($this->getServerPath(), '/') . '/404.html';
114114
$errorDocument404->setArguments(['404', $new404Path]);
115115
}
116116

tests/phpMyFAQ/Setup/EnvironmentConfiguratorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function testAdjustRewriteBaseHtaccessUpdatesErrorDocumentWithRootPath():
102102
<IfModule mod_rewrite.c>
103103
RewriteEngine On
104104
RewriteBase /phpmyfaq-test/
105-
ErrorDocument 404 /phpmyfaq-test/index.php?action=404
105+
ErrorDocument 404 /404.html
106106
</IfModule>
107107
HTACCESS;
108108
file_put_contents($htaccessPath, $htaccessContent);
@@ -115,7 +115,7 @@ public function testAdjustRewriteBaseHtaccessUpdatesErrorDocumentWithRootPath():
115115

116116
// Read the .htaccess file and verify ErrorDocument 404 is set correctly
117117
$htaccessContent = file_get_contents($htaccessPath);
118-
$this->assertStringContainsString('ErrorDocument 404 /index.php?action=404', $htaccessContent);
118+
$this->assertStringContainsString('ErrorDocument 404 /404.html', $htaccessContent);
119119
}
120120

121121
/**
@@ -130,7 +130,7 @@ public function testAdjustRewriteBaseHtaccessUpdatesErrorDocumentWithSubdirector
130130
<IfModule mod_rewrite.c>
131131
RewriteEngine On
132132
RewriteBase /
133-
ErrorDocument 404 /index.php?action=404
133+
ErrorDocument 404 /404.html
134134
</IfModule>
135135
HTACCESS;
136136
file_put_contents($htaccessPath, $htaccessContent);
@@ -143,6 +143,6 @@ public function testAdjustRewriteBaseHtaccessUpdatesErrorDocumentWithSubdirector
143143

144144
// Read the .htaccess file and verify ErrorDocument 404 is set correctly
145145
$htaccessContent = file_get_contents($htaccessPath);
146-
$this->assertStringContainsString('ErrorDocument 404 /faq/index.php?action=404', $htaccessContent);
146+
$this->assertStringContainsString('ErrorDocument 404 /faq/404.html', $htaccessContent);
147147
}
148148
}

0 commit comments

Comments
 (0)