Porblem with remove trailing slash and non-www to www - using .htaccess
- by HoanNguyen
I'm facing an issue with .htacess when combining 2 mod_rewrite at the same time:
remove trailing slash
redirect non-www to www
Here is my .htaccess file
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# Redirect non-www to www
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
RewriteRule ^(.+)/$ http://www.domain.com/$1 [R=301,L]
# Remove trailing slash
RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
They worked perfectly when I just used one of them, but when i put them together, the page just keep loading like forever.
Please help me to find a way that can use both of them in the same .htaccess :(
Many thanks :)