在我的WordPress网站中使用WP数据库参与者时,URL重写规则不起作用

时间:2014-11-07 作者:Ioan Vizitiu

我在一个使用WordPress开发的网站上使用WP参与者数据库插件,我正在尝试转换:

http://mysite.com/subfol1/subfol2/?listpage=3&search_field=none&value=&operator=LIKE&sortBy=denumire&ascdesc=asc&submit=&sortstring=denumire&orderstring=asc#participants-list

进入

http://mysite.com/subfol1/subfol2/3/

我的htaccess如下所示:

SetEnv no-gzip dont-vary
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^index\\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\\.php)$ $2 [L]
RewriteRule . index.php [L]

    RewriteRule ^produse/piese-schimb-utilaje-agricole/([0-9]+)/?$ ^produse/piese-schimb-utilaje-agricole/?listpage=$1&search_field=none&value=&operator=LIKE&sortBy=denumire&ascdesc=asc&submit=&sortstring=denumire&orderstring=asc#participants-list [NC,L]
我上次的重写规则不起作用。我哪里出错了?

谢谢你回答我的问题!

1 个回复
SO网友:Kevin Cristiano

我会尝试改变你规则的顺序。一旦默认WP规则运行,您的URL将被重写,并且您的上一条规则将不起作用。

SetEnv no-gzip dont-vary
RewriteEngine On
RewriteRule ^produse/piese-schimb-utilaje-agricole/([0-9]+)/?$ ^produse/piese-schimb-utilaje-agricole/?listpage=$1&search_field=none&value=&operator=LIKE&sortBy=denumire&ascdesc=asc&submit=&sortstring=denumire&orderstring=asc#participants-list [NC,L]

# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^index\\.php$ - [L]

# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\\.php)$ $2 [L]
RewriteRule . index.php [L]

结束