Anwsion1.0设置Rewrite伪静态
1, 按照系统提示安装Anwsion问答系统
2, 安装完成之后,修改对应网页服务器的配置文件
如果是你安装在网站根目录下:
nginx:在对应的nignx.conf文件里面添加
location / {
if (!-e $request_filename)
{
rewrite (.*) /index.php;
}
}
Apache:在对应的httpd.conf或者.htaccess里面添加
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
IIS6 Rewrite组件:在对应的配置文件httpd.ini里面添加
[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
RewriteRule /$ /? [L]
RewriteRule ^/topic/(.*) /\?\/topic/$1 [L]
RewriteRule ^/users/(.*) /\?\/users/$1 [L]
RewriteRule ^/notifications/(.*) /\?\/notifications/$1 [L]
RewriteRule ^/inbox/(.*) /\?\/inbox/$1 [L]
RewriteRule ^/follow/(.*) /\?\/follow/$1 [L]
RewriteRule ^/people/(.*) /\?\/people/$1 [L]
RewriteRule ^/setting/(.*) /\?\/setting/$1 [L]
RewriteRule ^/logout/(.*) /\?\/logout/$1 [L]
RewriteRule ^/publish/(.*) /\?\/publish/$1 [L]
RewriteRule ^/feature/(.*) /\?\/feature/$1 [L]
RewriteRule ^/home/(.*) /\?\/home/$1 [L]
RewriteRule ^/account/(.*) /\?\/account/$1 [L]
RewriteRule ^/login/(.*) /\?\/login/$1 [L]
RewriteRule ^/reader/(.*) /\?\/reader/$1 [L]
RewriteRule ^/search/(.*) /\?\/search/$1 [L]
RewriteRule ^/crond/(.*) /\?\/crond/$1 [L]
RewriteRule ^/admin/(.*) /\?\/admin/$1 [L]
RewriteRule ^/invitation/(.*) /\?\/invitation/$1 [L]
RewriteRule ^/m/(.*) /\?\/m/$1 [L]
RewriteRule ^/question/(.*) /\?\/question/$1 [L]
RewriteRule ^/category/(.*) /\?\/home/explore/category/$1 [L]
如果你是安装在:您的域名/xxx/这样的目录下面,对应的配置文件分别为:
nginx:在对应的nignx.conf文件里面添加
location /xxx/ {
if (!-e $request_filename)
{
rewrite (.*) /xxx/index.php;
}
}
Apache:在对应的httpd.conf或者.htaccess里面添加
<IfModule mod_rewrite.c>
RewriteBase /xxx/
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /xxx/index.php
</IfModule>
IIS6 Rewrite组件:在对应的配置文件httpd.ini里面添加
[ISAPI_Rewrite]
# 3600 = 1 hour
CacheClockRate 3600
RepeatLimit 32
RewriteRule /$ /? [L]
RewriteRule ^/topic/(.*) /\?\/topic/$1 [L]
RewriteRule ^/users/(.*) /\?\/users/$1 [L]
RewriteRule ^/notifications/(.*) /\?\/notifications/$1 [L]
RewriteRule ^/inbox/(.*) /\?\/inbox/$1 [L]
RewriteRule ^/people/(.*) /\?\/people/$1 [L]
RewriteRule ^/setting/(.*) /\?\/setting/$1 [L]
RewriteRule ^/logout/(.*) /\?\/logout/$1 [L]
RewriteRule ^/publish/(.*) /\?\/publish/$1 [L]
RewriteRule ^/feature/(.*) /\?\/feature/$1 [L]
RewriteRule ^/home/(.*) /\?\/home/$1 [L]
RewriteRule ^/account/(.*) /\?\/account/$1 [L]
RewriteRule ^/login/(.*) /\?\/login/$1 [L]
RewriteRule ^/reader/(.*) /\?\/reader/$1 [L]
RewriteRule ^/search/(.*) /\?\/search/$1 [L]
RewriteRule ^/crond/(.*) /\?\/crond/$1 [L]
RewriteRule ^/admin/(.*) /\?\/admin/$1 [L]
RewriteRule ^/invitation/(.*) /\?\/invitation/$1 [L]
RewriteRule ^/m/(.*) /\?\/m/$1 [L]
RewriteRule ^/question/(.*) /\?\/question/$1 [L]
RewriteRule ^/category/(.*) /\?\/home/explore/category/$1 [L]
3, 以管理员身份登录,进入管理后台 => 全局 => 站点功能 => 开启 Rewrite 伪静态:
4, 在URL 自定义路由每行一条规则,中间使用===隔开,左边为站点默认 URL 模式,右边为替换后的 URL 模式, 链接以 / 开头, (:num) 代表数字, (:any) 代表任意字符。(未来版本会提供一些默认样式)
官网当前的样式规则参考:
/home/explore/===/explore/
/home/explore/(:any)===/explore/(:any)
/home/explore/category-(:num)===/category/(:num)
/account/login/===/login/
/account/logout/===/logout/
/account/setting/(:any)/===/setting/(:any)/
5, 点击保存随即启用伪静态
阅读全文
收起全文