I’m trying to rewrite this non existing url:
to this working wordpress url:
http://myshop.com/shop/category/medical
(but visitor must not see the full wordpress url)
.
.
.
And by other hand I need to rwwrite the url products from that category:
http://myshop.com/medical/my_friendly_unique_url_product
to:
http://myshop.com/shop/category/medical/my_friendly_unique_url_product
server {
root /var/www/myshop.com;
server_name myshop.com www.myshop.com;
include global/global.conf;
include global/wordpress.conf;
location /medicals {
# http://myshop.com/medicals
# to
# http://myshop.com/shop/category/medicals/
rewrite ^/medicals$ /shop/category/medicals break;
# http://myshop.com/medicals/dinamic_unique_url_product
# to
# http://myshop.com/shop/category/medicals/dinamic_unique_url_product
rewrite ^/medicals/(.*)$ /shop/category/medicals/$1 break;
}
}
2
Answers
I found solution using add_rewrite_rule wordpress function, put this code in functions.php theme or in a plugin:
Your apache rewrite rules do not perform rewrites like you have shown in your question. The
http://myshop.com/medical/my_friendly_unique_url_product
request will be rewritten tohttp://myshop.com/shop/my_friendly_unique_url_product
, not thehttp://myshop.com/shop/category/medical/my_friendly_unique_url_product
.To perform the same rewrites with the nginx, try this:
To rewrite the
http://myshop.com/medical/my_friendly_unique_url_product
request to thehttp://myshop.com/shop/category/medical/my_friendly_unique_url_product
, use this instead: