I am trying to combine two rules for .htaccess. First, I need to remove the ".php" extension and add a "/" sign to the end of the url. Then I need to redirect the non-www version of the domain to www. My design doesn't work. Please tell me where is the mistake?
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
For example: domain.com/page.php -> I need www.domain.com/page/ (for multiple pages)
Thanks!