URL重写wordpress

时间:2016-11-05 23:26:54

标签: wordpress mod-rewrite

我想使用add_rewrite_rule在wordpress中重写我的帖子url。仅在设置了query_var操作时。 示例:example.com/my-post-name-slug/?action=query_action 收件人:example.com/my-post-name-slug/query_action

有可能吗?

htaccess的

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteBase /hot/
RewriteRule ^ajax/([^/]*)/([^/]*).html$ /hot/wp-admin/admin-ajax.php?action=$1&movie_id=$2 [L]

RewriteCond %{REQUEST_FILENAME} ^\?action\=$ 
RewriteCond ^\?action\= ^/?$

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /hot/index.php [L]


</IfModule>

# END WordPress

更新:解决

add_rewrite_rule('^slug/([^/]*)/([^/]*)/?','index.php?post_type=tpp&name=$matches[1]&action-query=$matches[2]','top');

0 个答案:

没有答案