简体   繁体   中英

.htaccess 301 redirect, URLs have different identifiers

here is my problem. Lets say these pages show details about a home that is being sold.

I have an old URL like:

www.example.com/home-details-12345.html

After a website redesign, the new URL looks like:

www.example.com/new-york-home-56789/

Where 12345 and 56789 are both unique identifiers for that home. So, I'm trying to redirect an old URL that used id1 to identify the home in the database, to a new URL that uses another identifier, id2. Basically, the URLs have nothing in common.

I can however retrieve id2 based on id1. So, my question is, how can I achieve this? Bear in mind there are over 100K homes, so manual redirects are out of the question.

I guess I need to make a RewriteRule for home-details-id1.html to a script, like getPage.php , where I can retrieve id2 using id1 , and make a second redirect to the correct page.

But how do I do this? How will google handle this from a SEO point of view? Thank you!

I'm no SEO expert, but I guess Google (or any other search engine for that matter) will recognize HTTP 301 redirection as "Moved permanently", so will try to index old URLs instead new ones. You could do a silent redirect by pointing Your RewriteRule to php script that would include old url (ie. include("home-details-12345.html"); ).

However, that will produce quite a lot of overhead, and You really don't want to do that. Try to change Your software's logic so it complies with Your front-end - it's really the best practice for theese kind of issues, and even though it'll cost You some time, it WILL pay off in the future.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM