I have performed multiple searches and have yet to find what i am looking for.
I need to perform some URL rewrites but I don’t have the expertise and knowledge to code the rewrites. I have just begun learning regex and apache URL rewriting.
Onto the problem.
The website I would like to use these re-directs on is a .com domain so users will be coming from multiple countries. On the website there is an online shop. On the initial landing page you are able to select which country you are from and it will take you to
www.domain.com/*country*/
which has the online shop.
Now this is where it gets complicated.
Depending on the country the user clicked, I would like to append that countries name to the URL after they have clicked on a product and entered the shop.
E.G "www.domain.com/*country*/*product-category*/
At the moment, when you click on a product after selecting your country it goes to
www.domain.com/*product-category*/
The site is running WordPress.
Not sure what other information is required.
Thanks Guys!
If you have control over the implementation of that online shop implementation then a solution might be quite easy: as said you somehow have to make sure that all urls sent out from that shop, so urls one can click/select inside the shop navigation, carry the chosen country coding within. Since the shop is called with that information in the first place the information is available and actually perfectly easy usable the way you describe the structure of the base url:
www.domain.com/*country*/
. Easy to use since the country code is part of the base url of the shop, not some arbitrary argument that has to be handled in an explicit manner. So all you have to take care of is this: make the shop use relative links in all urls it sends out to the client. Relative links are just relative paths (so a path without a leading slash(/
)). Browsers handle relative links by prepending the base url of the current page loaded to create a full url. So in your situation this means:www.domain.com/*country*/
product/123456/action/buy
(just an example)www.domain.com/*country*/product/123456/action/buy
This is exactly what you want: you do not have to handle/specify the country code in an explicit manner, yet it is contained in all urls. You “just” have to make sure you consequently use relative links in that shop implementation.
A side note: in general one should always prefer relative links to absolute links or urls, since it keeps implementations flexible, relocatable and portable. Only references to external targets should be coded as urls.
Other approaches might be these:
In wordpress there is a permalink option to declare custom url. its easy to use but i am not sure about your case.