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 :)
I do not know how to add the trailing slash, but adding www in front of URLs are quite simple. Here's what im using to add the www before an url:
Googled for the trailing slash-thingy and found this article: http://www.mydigitallife.info/2007/03/19/add-trailing-slash-to-the-end-of-the-url-with-htaccess-rewrite-rules/
Hope this helps :-)
This will work for any domain:
This will add the slash when necessary. (
%{REQUEST_URI}
will be/
with a request for root, or/whatever
if you requestdomain.com/whatever
.) It also won't put in two slashes (//
) for the main domain as the other solution does. TheDirectorySlash
directive ensures the slash is added where appropriate even if thewww
is already present.