RewriteEngine On

RewriteBase /qa

#解决某些ajax的系统调用默认使用当前路径的问题，比如 /q/abc 则会出现调用错误
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{QUERY_STRING} m=module_
RewriteRule ^(.*)$ index.php [QSA,PT,L]

#创建问题:
RewriteRule ^ask\/?$ index.php?m=module_qa_question.ui_question.create [NC,L]

#查看问题: /101/ or /101
RewriteRule ^([0-9]+)\/?$ index.php?m=module_qa_question.ui_question.custom_view_url&q_id=$1 [NC,QSA,L]

#查看问题: /101/question-name or /101/question-name/
RewriteRule ^([0-9]+)\/([^/]+)\/?$ index.php?m=module_qa_question.ui_question.view&q_id=$1&q_title=$2 [NC,QSA,L]

#编辑问题 /question/101/e/ or /question/101/e
RewriteRule ^question/([0-9]+)\/e\/?$ index.php?m=module_qa_question.ui_question.edit&q_id=$1 [NC,L]

#删除问题 /question/101/d/ or /question/101/d
RewriteRule ^question/([0-9]+)\/d\/?$ index.php?m=module_qa_question.ui_question.delete&q_id=$1 [NC,L]

#编辑答案 /answer/101/e/ or /answer/101/e
RewriteRule ^answer/([0-9]+)\/e\/?$ index.php?m=module_qa_answer.ui_answer.edit&a_id=$1 [NC,L]

#创建答案 /answer or /answer/
RewriteRule ^question/([0-9]+)\/answer\/?$ index.php?m=module_qa_answer.ui_answer.create&q_id=$1 [NC,L]

#索引问题 /all/newest
RewriteRule ^(all|myq|myc|mya)\/?$ $1/newest [NC,R,L] #默认都指向newest
RewriteRule ^(all|myq|myc|mya)\/(newest|newanswer|score|concerned|unanswer|answer|views)\/?$ index.php?m=module_qa_question.ui_question.index&cat=$1&sort=$2 [NC,QSA,L]
# 含tag的链接 /myq/newest/tagid/
RewriteRule ^(all|myq|myc|mya)\/(newest|newanswer|score|concerned|unanswer|answer|views)\/([^/]+)\/?$ index.php?m=module_qa_question.ui_question.index&cat=$1&sort=$2&tag=$3 [NC,QSA,L]

#帐号退出
RewriteRule ^logout\/?$ index.php?m=module_qa_account.ui_account.logout [NC,QSA,L]

#帐号登录
RewriteRule ^login\/?$ index.php?m=module_qa_account.ui_account.login [NC,QSA,L]

#注册帐号
RewriteRule ^register\/?$ index.php?m=module_qa_account.ui_account.register [NC,QSA,L]

#待激活页面
RewriteRule ^to-activate\/?$ index.php?m=module_qa_account.ui_account.to_activate [NC,QSA,L]

#激活帐号链接
RewriteRule ^activate\/?$ index.php?m=module_qa_account.ui_account.activate [NC,QSA,L]

#修改帐号密码
RewriteRule ^change-password\/?$ index.php?m=module_qa_account.ui_account.change_password [NC,QSA,L]

#重置密码
RewriteRule ^reset-password\/?$ index.php?m=module_qa_account.ui_account.reset_password [NC,QSA,L]

#忘记密码
RewriteRule ^forget-password\/?$ index.php?m=module_qa_account.ui_account.forget_password [NC,QSA,L]

#重发激活信件
RewriteRule ^resend-activate-mail\/?$ index.php?m=module_qa_account.ui_account.resend_activate_mail [NC,QSA,L]

#用户信息面板
RewriteRule ^account-panel\/?$ index.php?m=module_qa_portal.ui_portal.panel_user_info [NC,QSA,L]

#关于
RewriteRule ^about\/?$ index.php?m=module_qa_portal.ui_portal.about [NC,L]

#联系我们
RewriteRule ^contact\/?$ index.php?m=module_qa_portal.ui_portal.contact [NC,L]

#服务条款
RewriteRule ^service\/?$ index.php?m=module_qa_portal.ui_portal.service [NC,L]

#隐私政策
RewriteRule ^privacy\/?$ index.php?m=module_qa_portal.ui_portal.privacy [NC,L]
