.htaccess error handling not working
Posted: Tue Sep 03, 2024 2:24 pm
I have installed CMSMS 2.2.21 that replaces our old website and did create a new website entirely. Using pretty URL.
because of google results that link to our old website, I need to redirect some pages. I had hoped to be able to do this in .htaccess as I always do with my static websites.
Redirect geschichte/stiftung https://www.domain.ch/geschichte
But nothing works. I always get a white page with Error message on top, instead of a redirected existing page.
I would also be okay with just 404 going to the home page instead.
ErrorDocument 404 https://www.domain.ch
I already identified that it is specifically RewriteRule ^(.+)$ index.php?page=$1 [QSA] that prevents this. Without it, at least the ErrorDocument 404 works.
So how can this be solved?
<IfModule rewrite_module>
RewriteEngine on
# If your CMSMS installation is in a subdirectory of your domain, you need to specify the relative path (from the root of the domain) here.
# In example: RewriteBase /[subdirectory name]
RewriteBase /
# Rewrites URLs in the form of /parent/child/grandchild but only rewrites if the requested URL is not a file or directory.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
</IfModule>
because of google results that link to our old website, I need to redirect some pages. I had hoped to be able to do this in .htaccess as I always do with my static websites.
Redirect geschichte/stiftung https://www.domain.ch/geschichte
But nothing works. I always get a white page with Error message on top, instead of a redirected existing page.
I would also be okay with just 404 going to the home page instead.
ErrorDocument 404 https://www.domain.ch
I already identified that it is specifically RewriteRule ^(.+)$ index.php?page=$1 [QSA] that prevents this. Without it, at least the ErrorDocument 404 works.
So how can this be solved?
<IfModule rewrite_module>
RewriteEngine on
# If your CMSMS installation is in a subdirectory of your domain, you need to specify the relative path (from the root of the domain) here.
# In example: RewriteBase /[subdirectory name]
RewriteBase /
# Rewrites URLs in the form of /parent/child/grandchild but only rewrites if the requested URL is not a file or directory.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
</IfModule>