Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Primary domain rewrite for nginx works fine, but doesn't direct single pages

$
0
0
We just moved our website to a new domain, and the new website uses a totally different URL structure for all of the pages on the website.

For example, the old URL might look like: http://example.com/product/product-name/

The new URL would look like this: http://www.example2.com/product-p/product-name/pro.htm

Here's a snippet showing an example of what I'm working with:

------------------------------------------------------------------------------------

server{

location /product/product-name/ {
rewrite ^/product/product-name/
http://www.example2.com/product-p/product-name/pro.htm
permanent;
}

server_name example.com www.example.com;
rewrite ^ $scheme://www.example2.com;

}

------------------------------------------------------------------------------------


As it's working now, http://www.example.com redirects to http://www.example2.com just fine.

However, if you try to visit http://www.example.com/product/product-name/ it doesn't redirect to http://www.example2.com/product-p/product-name/pro.htm, it simply redirects to the root domain http://www.example2.com

Does anyone know how we redirect the primary domain AND redirect single pages to their new page?

Thanks.

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>