Can someone please help me to force my website to redirect to using www. and ALWAYS add a slash at the end of any page? My htaccess file currently looks like this:
RewriteEngine on
RewriteRule blog/date/([^/]+)/?$ index.php?page=viewblog&date=$1
RewriteRule blog/([^/]+)/?$ index.php?page=viewblog&category=$1
RewriteRule blog/([^/]+)/([^/]+)/?$ index.php?page=viewblog&category=$1&title=$2
RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([a-zA-Z0-9]+)
Many thanks in advance 🙂
This will work for any domain:
This will add the slash when necessary. (
%{REQUEST_URI}will be/with a request for root, or/whateverif you requestdomain.com/whatever.) It also won’t put in two slashes (//) for the main domain as the other solution does. TheDirectorySlashdirective ensures the slash is added where appropriate even if thewwwis already present.