There are a few things I want done to the URLs of my site that I cannot seem the .htaccess file to do.
1 remove file extension f.e. example.com/file.php
should be example.com/file
2 remove the www. f.e. www.example.com
should be example.com
(I got this part to work, but I would hate it if after I put in fix and this no longer worked
3 no one should be able to see index.php at the end of root f.e. example.com/index.php
should be example.com
4 my blog page should have nice urls f.e. example.com/blog.php?article=the-name-of-article
should be example.com/blog/the-name-of-article
here is my current .htaccess file
rewrite URLs
Options +FollowSymLinks -MultiViews
rewriteengine on
RewriteBase /
## Hide .php extension
## To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,NC]
## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php
## remove www
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
## remove ugly part of url for blog.php
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
RewriteRule ^blog/(.*)$ blog.php?article=$1 [QSA,L]
when I try to go to blog/the-name-of-article
I get a internal server error.