<IfModule mod_rewrite.c>
# .htaccess
# ThinkSNS
#
# 为了正常启用URL Rewrite，请将apache配置文件中“LoadModule rewrite_module modules/mod_rewrite.so”
# 前的注释去掉，并将apache的DocumentRoot开启AllowOverride
# 
# 如下所示为apache下httpd.conf的代码片段：
# <Directory "YourDocumentRoot">
#   Options Indexes FollowSymLinks ExecCGI Includes
#   AllowOverride All
#   Order allow,deny
#   Allow from all
# </Directory>
#

# 是否开启URL Rewrite.
RewriteEngine On

# 根目录名称 [注意：前后都有"/"]
# 请将下面的“/thinksns/”替换成您的根目录名称。如：
# 如果您的站点地址为：http://abc.com，那么请将“/thinksns/”替换为"/"
# 如果您的站点地址为：http://abc.com/d/e/f，那么请将“/thinksns/”替换为"/d/e/f/"

# 基本
RewriteRule ^/?url/([a-zA-Z0-9]+)$                            shorturl.php?url=$1 [L]
RewriteRule ^/?w3g/?$                                         index.php?app=w3g&%{QUERY_STRING} [L]
RewriteRule ^/?wap/?$                                         index.php?app=wap&%{QUERY_STRING} [L]
RewriteRule ^/?admin/?$                                       index.php?app=admin&%{QUERY_STRING} [L]
RewriteRule ^/?index/?$                                        index.php?app=home&mod=Index&act=index&%{QUERY_STRING} [L]
RewriteRule ^/?home/?$                                        index.php?app=home&mod=User&act=index&%{QUERY_STRING} [L]
RewriteRule ^/?atme/?$                                        index.php?app=home&mod=User&act=atme&%{QUERY_STRING} [L]
RewriteRule ^/?favorite/?$                                    index.php?app=home&mod=User&act=collection&%{QUERY_STRING} [L]
RewriteRule ^/?comment/?$                                     index.php?app=home&mod=User&act=comments&%{QUERY_STRING} [L]
RewriteRule ^/?findfriend/?$                                  index.php?app=home&mod=User&act=findfriend&%{QUERY_STRING} [L]
RewriteRule ^/?login/?$                                       index.php?app=home&mod=Public&act=login&%{QUERY_STRING} [L]
RewriteRule ^/?adminlogin/?$                                  index.php?app=home&mod=Public&act=adminlogin&%{QUERY_STRING} [L]
RewriteRule ^/?logout/?$                                      index.php?app=home&mod=Public&act=logout&%{QUERY_STRING} [L]
RewriteRule ^/?register/?$                                    index.php?app=home&mod=Public&act=register&%{QUERY_STRING} [L]
RewriteRule ^/?sendPassword/?$                                index.php?app=home&mod=Public&act=sendPassword&%{QUERY_STRING} [L]
RewriteRule ^/?404/?$                                         index.php?app=home&mod=Public&act=error404&%{QUERY_STRING} [L]
RewriteRule ^/?notification/?$                                index.php?app=home&mod=Message&act=notify&%{QUERY_STRING} [L]
RewriteRule ^/?appmessage/?$                                  index.php?app=home&mod=Message&act=appmessage&%{QUERY_STRING} [L]

# 微博广场
RewriteRule ^/?square/?$                                      index.php?app=home&mod=Square&act=index&%{QUERY_STRING} [L]
RewriteRule ^/?square/topic/?$                                index.php?app=home&mod=Square&act=hot_topics&%{QUERY_STRING} [L]
RewriteRule ^/?square/star/?$                                 index.php?app=home&mod=Square&act=star&%{QUERY_STRING} [L]
RewriteRule ^/?square/top/?$                                  index.php?app=home&mod=Square&act=top&%{QUERY_STRING} [L]
RewriteRule ^/?square/app/?$                                  index.php?app=home&mod=Square&act=app&%{QUERY_STRING} [L]

# 私信
RewriteRule ^/?message/?$                                     index.php?app=home&mod=Message&act=index&%{QUERY_STRING} [L]
RewriteRule ^/?message/inbox/?$                               index.php?app=home&mod=Message&act=inbox&%{QUERY_STRING} [L]
RewriteRule ^/?message/outbox/?$                              index.php?app=home&mod=Message&act=outbox&%{QUERY_STRING} [L]
RewriteRule ^/?message/([0-9]+)/?$                            index.php?app=home&mod=Message&act=detail&id=$1&%{QUERY_STRING} [L]

# 设置
RewriteRule ^/?setting/?$                                     index.php?app=home&mod=Account&act=index&%{QUERY_STRING} [L]
RewriteRule ^/?setting/privacy/?$                             index.php?app=home&mod=Account&act=privacy&%{QUERY_STRING} [L]
RewriteRule ^/?setting/domain/?$                              index.php?app=home&mod=Account&act=domain&%{QUERY_STRING} [L]
RewriteRule ^/?setting/security/?$                            index.php?app=home&mod=Account&act=security&%{QUERY_STRING} [L]
RewriteRule ^/?setting/medal/?$                               index.php?app=home&mod=Account&act=medal&%{QUERY_STRING} [L]
RewriteRule ^/?setting/bind/?$                                index.php?app=home&mod=Account&act=bind&%{QUERY_STRING} [L]
RewriteRule ^/?setting/credit/?$                              index.php?app=home&mod=Account&act=credit&%{QUERY_STRING} [L]
RewriteRule ^/?setting/verified/?$                            index.php?app=home&mod=Account&act=verified&%{QUERY_STRING} [L]
RewriteRule ^/?setting/invite/?$                              index.php?app=home&mod=Account&act=invite&%{QUERY_STRING} [L]

# 用户空间
RewriteRule ^/?space/?$                                       index.php?app=home&mod=Space&act=index&%{QUERY_STRING} [L]
RewriteRule ^/?@([a-zA-Z0-9]+)/?$                             index.php?app=home&mod=Space&act=index&uid=$1&%{QUERY_STRING} [L]
RewriteRule ^/?space/([a-zA-Z0-9]+)/?$                        index.php?app=home&mod=Space&act=index&uid=$1&%{QUERY_STRING} [L]
RewriteRule ^/?space/([a-zA-Z0-9]+)/following/?$              index.php?app=home&mod=Space&act=follow&uid=$1&type=following&%{QUERY_STRING} [L]
RewriteRule ^/?space/([a-zA-Z0-9]+)/follower/?$               index.php?app=home&mod=Space&act=follow&uid=$1&type=follower&%{QUERY_STRING} [L]
RewriteRule ^/?space/([a-zA-Z0-9]+)/friend/?$                 index.php?app=home&mod=Space&act=follow&uid=$1&type=friend&%{QUERY_STRING} [L]
RewriteRule ^/?space/([a-zA-Z0-9]+)/application/?$            index.php?app=home&mod=Space&act=follow&uid=$1&type=application&%{QUERY_STRING} [L]
RewriteRule ^/?space/([a-zA-Z0-9]+)/applyme/?$                index.php?app=home&mod=Space&act=follow&uid=$1&type=applyme&%{QUERY_STRING} [L]
RewriteRule ^/?space/([a-zA-Z0-9]+)/profile/?$                index.php?app=home&mod=Space&act=profile&uid=$1&%{QUERY_STRING} [L]

# 微博
RewriteRule ^/?weibo/([0-9]+)/?$                              index.php?app=home&mod=Space&act=detail&id=$1&%{QUERY_STRING} [L]

# 搜索
RewriteRule ^/?topics/(.*)$				      index.php?app=home&mod=User&act=topics&domain=$1&%{QUERY_STRING} [L]
RewriteRule ^/?topics$				              index.php?app=home&mod=User&act=topics&%{QUERY_STRING} [L]
RewriteRule ^/?search/?$                                      index.php?app=home&mod=User&act=search&%{QUERY_STRING} [L]
RewriteRule ^/?search/user/?$                                 index.php?app=home&mod=User&act=searchuser&%{QUERY_STRING} [L]
RewriteRule ^/?search/tag/?$                                  index.php?app=home&mod=User&act=searchtag&%{QUERY_STRING} [L]

# 应用
RewriteRule ^/?app/add/?$                                     index.php?app=home&mod=Index&act=addapp&%{QUERY_STRING} [L]
RewriteRule ^/?app/edit/?$                                    index.php?app=home&mod=Index&act=editapp&%{QUERY_STRING} [L]
RewriteRule ^/?app/install/([0-9]+)/?$                        index.php?app=home&mod=Index&act=install&app_id=$1&%{QUERY_STRING} [L]

# 日志
RewriteRule ^/?app/blog/?$                                    index.php?app=blog&mod=Index&act=index&%{QUERY_STRING} [L]
RewriteRule ^/?app/blog/lastest/?$                            index.php?app=blog&mod=Index&act=news&%{QUERY_STRING} [L]
RewriteRule ^/?app/blog/following/?$                          index.php?app=blog&mod=Index&act=followsblog&%{QUERY_STRING} [L]
RewriteRule ^/?app/blog/my/?$                                 index.php?app=blog&mod=Index&act=my&%{QUERY_STRING} [L]
RewriteRule ^/?app/blog/([0-9]+)/?$                           index.php?app=blog&mod=Index&act=personal&uid=$1&%{QUERY_STRING} [L]
RewriteRule ^/?app/blog/detail/([0-9]+)/?$                    index.php?app=blog&mod=Index&act=show&id=$1&%{QUERY_STRING} [L]
# blog/Index/personal节点已存在, 所以去掉本条
# RewriteRule ^/?app/blog/([0-9]+)/category/([0-9]+)/?$       index.php?app=blog&mod=Index&act=personal&uid=$1&cateId=$2&%{QUERY_STRING} [L]
RewriteRule ^/?app/blog/post/?$                               index.php?app=blog&mod=Index&act=addBlog&%{QUERY_STRING} [L]
RewriteRule ^/?app/blog/edit/([0-9]+)/?$                      index.php?app=blog&mod=Index&act=edit&id=$1&%{QUERY_STRING} [L]
RewriteRule ^/?app/blog/manage/?$                              index.php?app=blog&mod=Index&act=admin&%{QUERY_STRING} [L]

# 相册
RewriteRule ^/?app/photo/?$                                   index.php?app=photo&mod=Index&act=index&%{QUERY_STRING} [L]
RewriteRule ^/?app/photo/all_albums/?$                        index.php?app=photo&mod=Index&act=all_albums&%{QUERY_STRING} [L]
RewriteRule ^/?app/photo/all_photos/?$                        index.php?app=photo&mod=Index&act=all_photos&%{QUERY_STRING} [L]
RewriteRule ^/?app/photo/albums/?$                            index.php?app=photo&mod=Index&act=albums&%{QUERY_STRING} [L]
RewriteRule ^/?app/photo/photos/?$                            index.php?app=photo&mod=Index&act=photos&%{QUERY_STRING} [L]
RewriteRule ^/?app/photo/album/([0-9]+)/?$                    index.php?app=photo&mod=Index&act=album&id=$1&%{QUERY_STRING} [L]
RewriteRule ^/?app/photo/photo/([0-9]+)/?$                    index.php?app=photo&mod=Index&act=photo&id=$1&%{QUERY_STRING} [L]
RewriteRule ^/?app/photo/multi_upload/?$                      index.php?app=photo&mod=Upload&act=flash&%{QUERY_STRING} [L]
RewriteRule ^/?app/photo/upload/?$                            index.php?app=photo&mod=Upload&act=index&%{QUERY_STRING} [L]
RewriteRule ^/?app/photo/edit/([0-9]+)/?$                     index.php?app=photo&mod=Manage&act=album_edit&id=$1&%{QUERY_STRING} [L]
RewriteRule ^/?app/photo/order/([0-9]+)/?$                    index.php?app=photo&mod=Manage&act=album_order&id=$1&%{QUERY_STRING} [L]

# 活动
RewriteRule ^/?app/event/?$                                   index.php?app=event&mod=Index&act=index&%{QUERY_STRING} [L]
RewriteRule ^/?app/event/events/?$                            index.php?app=event&mod=Index&act=personal&%{QUERY_STRING} [L]
RewriteRule ^/?app/event/post/?$                              index.php?app=event&mod=Index&act=addEvent&%{QUERY_STRING} [L]
RewriteRule ^/?app/event/edit/([0-9]+)/?$                     index.php?app=event&mod=Index&act=edit&id=$1&%{QUERY_STRING} [L]
RewriteRule ^/?app/event/detail/([0-9]+)/?$                   index.php?app=event&mod=Index&act=eventDetail&id=$1&%{QUERY_STRING} [L]
RewriteRule ^/?app/event/member/([0-9]+)/?$                   index.php?app=event&mod=Index&act=member&id=$1&%{QUERY_STRING} [L]

# 投票
RewriteRule ^/?app/vote/?$                                    index.php?app=vote&mod=Index&act=index&%{QUERY_STRING} [L]
RewriteRule ^/?app/vote/my/?$                                 index.php?app=vote&mod=Index&act=my&%{QUERY_STRING} [L]
RewriteRule ^/?app/vote/([0-9]+)/?$                           index.php?app=vote&mod=Index&act=personal&uid=$1&%{QUERY_STRING} [L]
RewriteRule ^/?app/vote/post/?$                               index.php?app=vote&mod=Index&act=addPoll&%{QUERY_STRING} [L]
RewriteRule ^/?app/vote/detail/([0-9]+)/?$                    index.php?app=vote&mod=Index&act=pollDetail&id=$1&%{QUERY_STRING} [L]

# 礼物
RewriteRule ^/?app/gift/?$                                    index.php?app=gift&mod=Index&act=index&%{QUERY_STRING} [L]
RewriteRule ^/?app/gift/receive/?$                            index.php?app=gift&mod=Index&act=receivebox&%{QUERY_STRING} [L]
RewriteRule ^/?app/gift/send/?$                               index.php?app=gift&mod=Index&act=sendbox&%{QUERY_STRING} [L]
RewriteRule ^/?app/gift/([0-9]+)/?$                           index.php?app=gift&mod=Index&act=personal&uid=$1&%{QUERY_STRING} [L]

# 招贴版
RewriteRule ^/?app/poster/?$                                  index.php?app=poster&mod=Index&act=index&%{QUERY_STRING} [L]
RewriteRule ^/?app/poster/posters/?$                          index.php?app=poster&mod=Index&act=personal&%{QUERY_STRING} [L]
RewriteRule ^/?app/poster/post/?$                             index.php?app=poster&mod=Index&act=addPosterSort&%{QUERY_STRING} [L]
RewriteRule ^/?app/poster/post/([0-9]+)/?$                    index.php?app=poster&mod=Index&act=addPoster&typeId=$1&%{QUERY_STRING} [L]
RewriteRule ^/?app/poster/edit/([0-9]+)/?$                    index.php?app=poster&mod=Index&act=editPoster&id=$1&%{QUERY_STRING} [L]
RewriteRule ^/?app/poster/detail/([0-9]+)/?$                  index.php?app=poster&mod=Index&act=posterDetail&id=$1&%{QUERY_STRING} [L]

# 群组
RewriteRule ^/?app/group/?$                                             index.php?app=group&mod=Index&act=newIndex&%{QUERY_STRING} [L]
RewriteRule ^/?app/group/index?$                                        index.php?app=group&mod=Index&act=newIndex&%{QUERY_STRING} [L]
RewriteRule ^/?app/group/my_post/?$                                     index.php?app=group&mod=Index&act=post&%{QUERY_STRING} [L]
RewriteRule ^/?app/group/replied/?$                                     index.php?app=group&mod=Index&act=replied&%{QUERY_STRING} [L]
RewriteRule ^/?app/group/comment/?$                                     index.php?app=group&mod=Index&act=comment&%{QUERY_STRING} [L]
RewriteRule ^/?app/group/atme/?$                                        index.php?app=group&mod=Index&act=atme&%{QUERY_STRING} [L]
RewriteRule ^/?app/group/groups/?$                                      index.php?app=group&mod=SomeOne&act=index&%{QUERY_STRING} [L]
RewriteRule ^/?app/group/class/?$                                       index.php?app=group&mod=Index&act=find&%{QUERY_STRING} [L]
RewriteRule ^/?app/group/search/?$                                      index.php?app=group&mod=Index&act=search&%{QUERY_STRING} [L]
RewriteRule ^/?app/group/add/?$                                         index.php?app=group&mod=Index&act=add&%{QUERY_STRING} [L]
RewriteRule ^/?app/group/([0-9]+)/?$                                    index.php?app=group&mod=Group&act=index&gid=$1&%{QUERY_STRING} [L]
RewriteRule ^/?app/group/([0-9]+)/search?$                              index.php?app=group&mod=Group&act=search&gid=$1&%{QUERY_STRING} [L]
RewriteRule ^/?app/group/([0-9]+)/detail/([0-9]+)/?$                    index.php?app=group&mod=Group&act=detail&gid=$1&id=$2&%{QUERY_STRING} [L]
RewriteRule ^/?app/group/([0-9]+)/invite/?$                             index.php?app=group&mod=Invite&act=create&gid=$1&%{QUERY_STRING} [L]
RewriteRule ^/?app/group/([0-9]+)/setting/baseinfo/?$                   index.php?app=group&mod=Manage&act=index&gid=$1&%{QUERY_STRING} [L]
RewriteRule ^/?app/group/([0-9]+)/setting/private/?$                    index.php?app=group&mod=Manage&act=privacy&gid=$1&%{QUERY_STRING} [L]
RewriteRule ^/?app/group/([0-9]+)/setting/member/?$                     index.php?app=group&mod=Manage&act=membermanage&gid=$1&%{QUERY_STRING} [L]
RewriteRule ^/?app/group/([0-9]+)/setting/announcement/?$               index.php?app=group&mod=Manage&act=announce&gid=$1&%{QUERY_STRING} [L]
RewriteRule ^/?app/group/([0-9]+)/setting/log/?$                        index.php?app=group&mod=Log&act=index&gid=$1&%{QUERY_STRING} [L]
RewriteRule ^/?app/group/([0-9]+)/bbs/?$                                index.php?app=group&mod=Topic&act=index&gid=$1&%{QUERY_STRING} [L]
RewriteRule ^/?app/group/([0-9]+)/bbs/post/?$                           index.php?app=group&mod=Topic&act=add&gid=$1&%{QUERY_STRING} [L]
RewriteRule ^/?app/group/([0-9]+)/bbs/edit/([0-9]+)/?$                  index.php?app=group&mod=Topic&act=edit&gid=$1&tid=$2&%{QUERY_STRING} [L]
RewriteRule ^/?app/group(?:/([0-9]+))?/bbs_reply/edit(?:/([0-9]+))?/?$  index.php?app=group&mod=Topic&act=editPost&gid=$1&pid=$2&%{QUERY_STRING} [L]
RewriteRule ^/?app/group/([0-9]+)/bbs/([0-9]+)/?$                       index.php?app=group&mod=Topic&act=topic&gid=$1&tid=$2&%{QUERY_STRING} [L]
RewriteRule ^/?app/group/([0-9]+)/file/?$                               index.php?app=group&mod=Dir&act=index&gid=$1&%{QUERY_STRING} [L]
RewriteRule ^/?app/group/([0-9]+)/file/upload/?$                        index.php?app=group&mod=Dir&act=upload&gid=$1&%{QUERY_STRING} [L]
RewriteRule ^/?app/group/([0-9]+)/member/?$                             index.php?app=group&mod=Member&act=index&gid=$1&%{QUERY_STRING} [L]

# 游戏
# 游戏积分提交URL修正
RewriteCond %{QUERY_STRING} (ac=save)
RewriteCond %{QUERY_STRING} (fgid=)
RewriteRule ^/?(app/game)?(.*)$                                         index.php?app=game&mod=Index&act=index&%{QUERY_STRING} [L]
RewriteRule ^/?app/game/([0-9]+)/?$                                     index.php?app=game&mod=Index&act=gameplay&gid=$1&%{QUERY_STRING} [L]
# 论坛
RewriteRule ^/?app/forum/?$                                             index.php?app=forum&mod=Index&act=index&%{QUERY_STRING} [L]
# 非法链接
RewriteRule ^/?([a-zA-Z0-9]+)$                                          index.php?app=home&mod=Public&act=error404&%{QUERY_STRING} [L]
</IfModule>