RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\..* [NC]
RewriteCond %{HTTP_HOST} !^[0-9]+\.[0-9]+\..+ [NC]
RewriteRule ^([^/]+) http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

ErrorDocument 404 /index.php?view=error&type=404

# Mod_Rewrite for AdaptCMS 2.0+

RewriteRule ^profile/?$ index.php?view=social
RewriteRule ^profile/edit/?$ index.php?view=social&do=edit
RewriteRule ^profile/edit2/?$ index.php?view=social&do=edit2
RewriteRule ^pages/?$ index.php?view=pages
RewriteRule ^rss/?$ index.php?view=rss

RewriteRule ^article/([0-9]+)/([^/]+)/?$ index.php?view=content&id=$1
RewriteRule ^article/([0-9]+)/([^/]+)/([^/]+)/?$ index.php?view=content&id=$1
RewriteRule ^content/([0-9]+)/([^/]+)/?$ index.php?view=content&id=$1
RewriteRule ^content/([^/]+)/([0-9]+)/([^/]+)/?$ index.php?view=content&id=$2
RewriteRule ^file/([0-9]+)/([^/]+)/?$ index.php?view=media&do=file&id=$1
RewriteRule ^media/([0-9]+)/([^/]+)/?$ index.php?view=media&do=gallery&id=$1
RewriteRule ^page/([0-9]+)/([^/]+)/?$ index.php?view=pages&id=$1
RewriteRule ^poll/([0-9]+)/?$ index.php?view=polls&id=$1
RewriteRule ^section/([^/]+)/?$ index.php?view=section&section=$1
RewriteRule ^tag/([^/]+)/?$ index.php?view=search&q=$1
RewriteRule ^profile/status/([0-9]+)/?$ index.php?view=social&do=status&id=$1
RewriteRule ^profile/blogs/add/?$ index.php?view=social&do=blogs&go=add
RewriteRule ^profile/blogs/([0-9]+)/([^/]+)/?$ index.php?view=social&do=blogs&id=$1
RewriteRule ^profile/([^/]+)/?$ index.php?view=social&username=$1
RewriteRule ^profile/([^/]+)/blogs/?$ index.php?view=social&do=blogs&username=$1
RewriteRule ^profile/([^/]+)/friends/?$ index.php?view=social&do=friends&username=$1
RewriteRule ^profile/([^/]+)/status/?$ index.php?view=social&do=status&username=$1

RewriteRule ^rss/([^/]+)/([^/]+)-([^/]+)/?$ index.php?view=rss&section=$1&field=$2&data=$3
RewriteRule ^rss/([^/]+)-([^/]+)/?$ index.php?view=rss&field=$1&data=$2
RewriteRule ^rss/([^/]+)/?$ index.php?view=rss&section=$1

RewriteRule ^friends/?$ index.php?view=social&do=friends
RewriteRule ^gallery/?$ index.php?view=media
RewriteRule ^login/?$ index.php?view=login
RewriteRule ^logout/?$ index.php?view=logout
RewriteRule ^media/?$ index.php?view=media
RewriteRule ^messages/?$ index.php?view=social&do=messages
RewriteRule ^poll-results/?$ index.php?results=yes
RewriteRule ^polls/?$ index.php?view=polls
RewriteRule ^register/?$ index.php?view=register
RewriteRule ^search/?$ index.php?view=search

RewriteRule ^archive/?$ index.php?view=content