用自定义链接重写长网址

时间:2018-11-26 02:33:16

标签: wordpress .htaccess url-rewriting routing

我有此链接:

www.example.com/wp-content/themes/site/modules/library/?pid=55

我想将其重写为:

www.example.com/customName/55

我尝试对.htaccess进行很多尝试都没有成功:

RewriteEngine On
RewriteBase  /wp-content/themes/site/modules/library/?pid=$1
RewriteRule https://www.example.com/customName/$1 

1 个答案:

答案 0 :(得分:0)

WordPress有自己的网址路由系统。您可以对其进行自定义以缩短您的长网址。如果您无法通过设置执行此操作,请在htaccess文件中使用以下规则:

RewriteEngine on


RewriteRule ^CustomName/([0-9]+)/?$ /wp-content/themes/site/modules/library/?pid=$1 [L,NC]
# other rules
相关问题