This question already has an answer here:
Redirect, Change URLs or Redirect HTTP to HTTPS in Apache - Everything You Ever Wanted to Know About Mod_Rewrite Rules but Were Afraid to Ask 5 answers
I have a website where the use of mod_rewrite.

RewriteRule ^([^/]*)/([^/]*)\.html$ /?systemdomain=$1&page-slug=$2 [L,QSA]
can generate a url such as

and this work perfectly without issue.

The physical path of this is located at


Now here is the issue, if I have a url such as; I will get a 404 error even though newdirectory exists (/homepages/profiles/newdirectory)

I will need to get access to
all which generate a 404. Any way of resolving this via .htaccess.

not sure if i should be modifying the rewrite or add some type of redirection. any help would be appreciated