Reputation: 11
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
Upvotes: 1
Views: 660
Reputation: 41219
You need to use %{REQUEST_FILENAME} in place of %{REQUEST_URI}
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ /404.php [L]
Upvotes: 1