开发者

WordPress and ReWriteRule

开发者 https://www.devze.com 2023-01-09 03:48 出处:网络
I have a product-details template in my theme that handles display for different products based on the URL.

I have a product-details template in my theme that handles display for different products based on the URL.

By default, WordPress will allow a number to be passed to the template page by appending to the URL: product-details/3/

However, I want to make this to be more SEO Friendly using a slug: product/sandals. Yet, when I do so, WordPress no longer finds the page by default.

I tried the following ReWriteRule with no luck.

RewriteR开发者_Python百科ule ^product/([\w\-]+)/?$ product-details/?slug=$1 [L]

How can I have this custom slug sent to the template. I would prefer to keep everything in WordPress, but am willing to add the ReWriteRule.


Credit to Richard for answering this in the OP comments. I've highlighted the resource for completeness and to mark this question answered.

http://codex.wordpress.org/Function_Reference/WP_Rewrite

0

精彩评论

暂无评论...
验证码 换一张
取 消