I’m trying (and failing) to use rewrite rules to redirect shorter/prettier URLs to the right page AND include values in the query string.
WP is installed at https://example.com, and the plugin creates a page called ‘foo’ which uses a value ‘bar’ passed in the query string to generate the content from custom database tables.
So an example full URL would be:
https://example.com/foo/?bar=XXXXXX
The ‘bar’ value would always be a string of between 6 and 8 alphanumeric chars with at least 1 dash(-).
I want to use rewrite rules (but am open to other suggestions) so that a shorter URL can be used, such as:
https://example.com/f/XXXXXX
I have tried using add_rewrite_rule as follows:
And, when I flush the rewrite rules by clicking save on the Permalinks Settings page in the Dashboard, the rule is added to the htaccess file just fine:
However, when I try to access:
https://example.com/f/XXXXXX
the page is just redirected to:
https://example.com/foo/
and is missing the needed bar=XXXXXX querystring so the relevant content does not load.
Can anyone please point out where I am going wrong wiht this or suggest an alternative?
- Hiện tại chúng tôi có hơn 25 nghìn bài văn mẫu các thể loại.
- Kho tài liệu, đề thi học sinh giỏi các lớp vô cùng phong phú.
- Mỗi ngày cập nhật hơn 100 đề thi chất lượng từ các website bán tài liệu lớn.
Tải đề thi VIP với giá siêu rẻ tại Vip.Dethihsg247.Com