I've tried searching and found nothing that helps me solve the following problem. I found this link on SO: https://stackoverflow.com/questions/1426056/good-htaccess-mod-rewrite-url-rewriting-tutorial but all of the links within it are 404 dead.
I'm trying to beautify the urls of my site so www.mysite.com/aboutus.php
is rewritten to look like www.mysite.com/aboutus
which works.
But I want to not do this on the admin/cms
directory as it stops the CMS from working. So ignore www.mysite.com/admin.php
The code I'm using is:
RewriteEngine On
# Unless directory, remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/$ http://mysite.com/$1 [R=301,L]
# Redirect external .php requests to extensionless url
RewriteCond %{THE_REQUEST} ^(.+)\.php([#?][^\ ]*)?\ HTTP/
RewriteRule ^(.+)\.php$ http://mysite.com/$1 [R=301,L]
# Resolve .php file for extensionless php urls
RewriteRule ^([^/.]+)$ $1.php [L]
I don't think I'm doing this correctly as it also takes the www
off of the start of the URL.
I have also found this SO: https://stackoverflow.com/a/9565288/1343827 which seems to do what I want, but I'm not 100% sure it will do what I want.
If anyone can help me rewrite this mod so it removes .php
from the end of links, but ignores this in the admin directory that'd be great.