2016-11-05 54 views
2

我想使用add_rewrite_rule在wordpress中重写我的帖子网址。只有在设置了query_var动作的情况下。 例如:example.com/my-post-name-slug/?action=query_action 收件人:example.com/my-post-name-slug/query_actionURL Rewrite wordpress

可能吗?

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 

UPDATE:解决

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

回答

0

你可以做

RewriteEngine叙述在
的RewriteCond%{REQUEST_FILENAME}^\行动\ = $
的RewriteCond?^\?动作\ =^/?$

应该工作

希望它帮助mukund2003

+0

它不工作 –

+0

嗯,,它吐出一个错误? – Mukund

+0

虐待重做它,我只是测试它,它dosent工作 – Mukund