如果找不到请求的URL,则在页面上重定向的htaccess规则

Dynamic url created is not the same as name of the page

Example:

The page name remains same example - example.php but the dynamic requested url is example-acd.php.

How to redirect to a new page if the dynamic url not found on the server.

Using this code:

RewriteCond %{REQUEST_URI} !-d
RewriteCond %{REQUEST_URI} !-f
RewriteRule ^.*$ /404.php [L]

It is working fine for the static url but not for the dynamic url

You need to use %{REQUEST_FILENAME} in place of %{REQUEST_URI}

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ /404.php [L]