0

I'm sorry I wasn't clear. English is not my first language. I have asked a colleague to help rewrite the question and I hope this clarifies what I am trying to achieve;

I have a page that describes my services:

https://www.example.com/my-services/

I then have another page that goes into more detail about the services offered in a particlaur location. To retrieve the variable data for this location-specific page, I use the URL:

https://www.example.com/my-services/?location=london

However, my boss does not want any URL paramaeters to be visible and wants this page URL to be generated in the browser as:

https://www.example.com/my-services/london/

I do not know how to achieve this "pretty URL". Any help and advice would be greatly appreciated.

Thanks in advance.

7
  • is your page name fixed? Note that WordPress rewrite rules don't map a pretty URL on to an arbitrary URL, they specifically map to index.php URLs with URL parameters, and those URL parameters are not GET parameters you can grab via $_GET they're query parameters aka get_posts( array ( these things here ) ); or $query = new WP_Query( [ 'queryvar' => 'value' ] ); The same stuff as posts_per_page etc Commented Aug 12 at 15:25
  • Also WP doesn't use the best rewrite rule that matches, it uses the first rewrite rule that matches, so what you're asking for if taken literally will break all support for child pages as it would interpret them as office/locations etc. I'd also note that even if your rewrite rule worked, it won't influence the canonical URLs or the URLs that get printed on the page Commented Aug 12 at 15:27
  • Thanks for your reply Tom, my page name is not fixed the {pagename} is wordpress structure of pagenames and I am currently appending query variables and I am able to use them right now but can not make them pretty or modify existing url and append variables in the same fashion, I would like if it gives priority to existing by default, url with dynamic parameters will be different than existing so I think there will not be any clash and if I can access them with query_vars it will be good for me to use further as good as I can access them, I hope you are getting what I want to convey, Thanks Commented Aug 13 at 5:55
  • Instead of hoping why not rewrite what you're trying to convey so it's a bit clearer? Avoid run-on sentences and punctuate appropriately. Commented Aug 14 at 12:07
  • @And look at this question : wordpress.stackexchange.com/questions/327895/… Commented Aug 19 at 12:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.