I need to create some rules in the .htaccess file so that certain conditions are met. For example, I want to show the file 404.shtml ( ErrorDocument 404 /404.shtml
) only in the case where the generated URL has the extension .html or .php (when it is misspelled of course or I don't find it on my site), in the other cases I don't ( which is when the page behaves as SPA).
Being SPA (single-page application), it always works on the same page and here I don't need to see the 404.shtml file . So I have the following and it is already working:
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME} !-l
Rewritecond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php [NC,L]
Now I want the opposite case when it is not on the page of type SPA . I would need some rule so that the 404.shtml page is seen , when the other internal pages are already and they always have the .html or .php extension. and they are not on the site (page not found).
Just as an example, it would be something like this:
IF (la pagina es SPA){
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME} !-l
Rewritecond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php [NC,L]
} else {
ErrorDocument 404 /404.shtml
}
Right now I have it like this in the .htaccess file :
...
...
RewriteCond %{REQUEST_FILENAME} !-s
RewriteCond %{REQUEST_FILENAME} !-l
Rewritecond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php [NC,L]
ErrorDocument 404 /404.shtml
...but the 404.shtml is never generated when the page doesn't exist.
In short, I need that, if the URL is within those managed by the SPA, it is redirected to the SPA and in another case it is redirected to a 404.shtml page
Can something like this be done from the .htaccess file ?