如何设置WeCenter的Rewrite伪静态及路由规则

1、请填写WeCenter在不同环境下的Rewrite伪静态的规则
2、WeCenter后台路由规则的填写
已邀请:

likfe

赞同来自:

###郑重声明
由于WeCenter的不完善,可能是Rewrite伪静态和路由规则的不匹配,导致伪静态化之后很多功能不能用,甚至有些页面404错误,故暂时只建议使用稳定路由规则:
{{{
/people/list/===/users/
/account/login/===/login/
/account/logout/===/logout/
/account/setting/(:any)/===/setting/(:any)/
}}}

likfe

赞同来自:

## Rewrite伪静态规则
### (1)、安装在网站根目录下:

1. **nginx:在对应的nignx.conf文件里面添加**
> location / {
> if (!-e $request_filename)
> {
> rewrite (.*) /index.php;
> }
> }


2. **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 >


3. **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]

### (2)、安装在:您的域名/xxx/这样的目录下面:

1. **nginx:在对应的nignx.conf文件里面添加**
> location /xxx/ {
> if (!-e $request_filename)
> {
> rewrite (.*) /index.php;
> }
> }


2. **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>


3. **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]

## 路由规则规则
在URL自定义路由每行一条规则,中间使用===隔开,左边为站点默认 URL 模式,右边为替换后的 URL 模式, 链接以 / 开头, (:num) 代表数字, (:any) 代表任意字符。(未来版本会提供一些默认样式)
下面是我的样式规则参考:
> /question/square/===/question/
> /question/(:any)===/q_(:any).html
> /topic/square/===/topic/
> /topic/(:any)===/t_(:any).html
> /article/square/===/article/
> /article/(:any)===/a_(:any).html
> /people/list/===/user/
> /people/(:any)===/p_(:any).html
> /account/login/===/login/
> /account/logout/===/logout/
> /account/setting/(:any)/===/setting/(:any)/

这里给大家解释一下,内容并不难(注:在后台系统自动生成的有bug):
> ① /question/square/===/question/
> ② /question/(:any)===/q_(:any).html

以前两行为例,后面的相似:
1. **①行和②行不能换位置**:如果①行和②行换位置了,会导致访问`/question/square/`时变成`q_square/.html`,是的你没看错,多了一个`/`,这是因为**规则靠前的优先级高**。于是`/question/square/`会按照`/question/(:any)===/q_(:any).html`来解析,那么`square/`对应于`(:any)`,经过`q_(:any).html`转换成了`q_ square/ .html`
以此类推,其他规则的①行和②行也不能换位置
2. **单词对应的介绍**:
`/question/square/`是问题列表页
`/question/(:any)`是单个问题内容页
以此类推,`topic`是主题,`article`是文章,`people`是用户
3. **最后3行不建议修改**
> /account/login/===/login/
> /account/logout/===/logout/
> /account/setting/(:any)/===/setting/(:any)/

要回复问题请先登录注册