: How to handle non-existent subdirectories? I have a dynamic website with friendly URLs. Example: Instead of /user.php?id=123, I have /user/123 Instead of /index.php?category=fishes, I have /fishes
I have a dynamic website with friendly URLs. Example:
Instead of /user.php?id=123, I have /user/123
Instead of /index.php?category=fishes, I have /fishes
But, how do I handle non-existent subdirectories such as /about/123? Currently it gives a 200 success instead of a 404 not found error. Is there a way to deal with non-existent subdirectories in Apache config and at the same time allow for friendly URLs? Or do I have to handle this individually for each PHP script?
More posts by @Kevin317
1 Comments
Sorted by latest first Latest Oldest Best
If you ensured all the wanted folder names were present in the regex list then all others could be redirected to a 404 page using this .htaccess script:
# If friendly URL dynamic folder not present in URL then respond HTTP 404
RewriteRule ^(user|fishes) - [R=404]
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.