redirect Index.php to root htaccess - Joomla
===

I've been using the codes below to redirect the index.php to root, change the non-www URL version to www version and remove the trailing slashes from the end of URLs. I have several problem using these codes and i'm sure I'm doing something wrong as far as how I structured them.

1) it seems the code redirect all the index.php file to root including sub folders which causes problem loging into backend administrator panel.

2) I have problem with submitting articles on K2 from frontend 

I think i need to modify the code to fix the problem. I looked through the forum and tried some other codes that was suggested but none of the worked for me. This is the code I use. (i inserted them in the custom redirection section of htaccess file. 

    #index.php to root
    RewriteCond %{THE_REQUEST} ^.*/index.php 
    RewriteRule ^(.*)index.php$ http://www.mywebsite.com/$1 [R=301,L] 
    
    #non-www to www
    rewritecond %{http_host} ^mywesbite\.com
    rewriterule (.*) http://www.mywebsite.com/$1 [r=301,L]
    
    #remove slashes
    RewriteCond %{HTTP_HOST} ^(www.)?mywebsite\.com$ [NC]
    RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]

Your help is greatly appreciated!
