Welcome! Log In Create A New Profile

Advanced

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

Posted by mrdail87 
Primary domain rewrite for nginx works fine, but doesn't direct single pages
November 20, 2015 11:08AM
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.



Edited 1 time(s). Last edit at 11/20/2015 11:08AM by mrdail87.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 145
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready