I am attempting to rewrite a certain page (example.com/php/otherPages.php?pageSlug=example) to example.com/example.html while still displaying the content found on the said page. However I already have similar rewrite rules in my .htaccess that are messing with how the rule works. My code is below so you can better see what I'm talking about.
The top 4 rewrite rules work however the bottom one (the rule that is supposed to execute what is explained above) doesn't. When I take the bottom rule and place it at the top it works however, the rest of the code doesn't. I have determined that this is because ^([^/\.]+)\.html?$ is the same throughout the file. Is there any way to fix this or another code that I can put in that will function in the same way that I want it to function?
Follow-up: It's possible that you've misunderstood the relationship between target and pattern. The pattern, the part on the left, is what the user (whether human or robot) requests. Your server compares each request against the pattern; if there's a match, it does the stuff on the right. This applies in a general way to any Apache activity that involves evaluating some aspect of the request.
The two targets
each correspond to some URL that the user has requested. But the request can't simply be ([^/.]+)\.html There has to be some way for the server to know if the person really wants statePage.php or otherPages.php. If there's no way to tell the URLs apart, you have to either list each group by name, or let a preliminary php script sort them out.
Oh, and: In a redirect, it might be appropriate to use the form \.html? with optional l, especially if you've got a lot of outside sites pointing to the wrong form of your URL. But in a rewrite you can only permit one form. Otherwise you'll have duplicate content in the most literal way (an html version and an htm version of every URL).