Sorry if this doesn't belong here. Please move it to a more appropriate subforum if necessary.
I inherited a website from a coworker that left about a month ago. It uses .htaccess heavily for creating "pretty links", a ton of 301 redirects, and several other things that I'm not quite sure exactly what they're for. Anyway, I was tasked with creating a mobile version of their website. The creation went fine and it was put in a /mobile/ folder, so you would go to www.example.com/mobile/ to see the mobile version of the website.
Then out of nowhere the client tells us it's not going to be in a subfolder and instead in a subdomain. Thanks for telling us a month ago. Anyway, they set up the subdomain themselves in the control panel (in the process taking down the site and trying to blame us for it - but that's another story) and it's m.example.com. So basically I've been tasked with making the former site work with the subdomain. Should be simple enough, just change some of the lines in the .htaccess file to reflect the changes, but so far no dice.
On the server there is a /mobile/ folder with all the necessary PHP files (about.php, privacy-policy.php, index.php, etc.). In the .htaccess file there's a line for each of these files to remove the .php extension to make the links look a little nicer.
RewriteRule ^mobile/about?$ mobile/about.php [L]
RewriteRule ^mobile/contact?$ mobile/contact-us.php [L]
RewriteRule ^mobile/solutions?$ mobile/solutions.php [L]
#And so on...
These work as expected and everyone was happy with everything until the client decided to put it on a subdomain. So I thought maybe all I needed to do was modify the lines slightly...
RewriteRule ^m.example.com/about?$ mobile/about.php [L]
#And so on...
...but this gives me an error page with "Multiple choices" and the following message:
The document name you requested (/about) could not be found on this server. However, we found documents with names similar to the one you requested.
Available documents:
/about.php (common basename)
This happens if I try to go to m.example.com/about, but if I go to m.example.com/about.php the page displays as expected. So that lead me to believe that if I could just figure out how to strip the .php extension off the URL I could get all this to work. I did a ton of Googling (I have 24 tabs open right now) and found the following code:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*?)/?$ $1.php [L]
Which does remove the .php extension but I am getting a 404 error now instead, and nothing I do resolves it. Furthermore, when I don't use the above code, nothing I do resolves the Multiple Choices message either. I know it has something to do with the file structure because in the root of the web folder there are files with the same name (about.php, privacy-policy.php, etc.) because the website is really three sites (well, four with the mobile now) in one. This was not my decision, just to be clear, but I am confident this is causing the issue. In any case, no matter what I do I cannot get past the Multiple Choices message or the 404 message. Oh, and I am doing this live. The developer that left wasn't able to get the site working properly on our development server, so everything has to be done live. Lovely.
I have also commented out all the individual redirect lines and tried putting this in:
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
RewriteRule ^mobile/(.*)$ http://m.example.com/$1.php [L,QSA,R=301]
But this also produces the Multiple Choices message.
I am at a loss because I'm not very experienced with .htaccess files and I feel like I have exhausted my (very) limited knowledge, and everything I have found online seems to point in the right direction but it never pans out. I've had another coworker work with me for about an hour but he was stumped as well. All I want to do is express my frustration and to my manager but he is currently in a meeting. Arg.
The end goal is to have files such as /mobile/about.php redirect to m.example.com/about.
Any help or insight would be greatly appreciated. Thank you for reading all this!